The following doesn't work for me:
#!/bin/bash
commands () {
cd ~/Yola
pwd
}
export -f commands
konsole --noclose -e "bash -c 'commands'"
New konsole opens, but commands are not executed.
Double quotes around a string parsed as an argument mean that string is run as a child process, i.e. it's contents do not affect the parent process.
Single quotes don't do anything to the characters between them, so switch double quotes for single quotes on your last line, like so:
konsole --noclose -e 'bash -c commands'
(Your commands
function doesn't need any quotes around it.) If you are running a long list of commands in this way, I recommend the -x
flag which prints out commands and output in order. Use konsole --noclose -e 'bash -cx commands'
to get the following print out:
+ commands
+ cd ~/Yola
+ pwd
/home/Yola