I'm using Xubuntu with XFCE.

I would like to write a bash script which opens a new tab in the xfce4-terminal. In this tab, the bash should be running with an altered PATH environment variable.

Currently, the shell script looks like that:

xfce4-terminal \
    --tab \
    --title=GCC \
    --command 'bash'

It is opening a new bash-tab in the terminal just like it should. However, I would additionally like this environment variable to be set:

export PATH=/home/manuel/toolchains/gcc-arm-none-eabi-4_9-2014q4/bin:$PATH

I suppose it's possible to provide this command as argument to the bash command in my shell script. However, even after studying the man page I couldn't figure it out.

1 Answer 1


Use the env command.

env runs a command with a modified environment. Synopses:

env [option]... [name=value]... [command [args]...]

So you in your specific case you should run the following:

xfce4-terminal \
    --tab \
    --title=GCC \
    --command "env PATH=/home/manuel/toolchains/gcc-arm-none-eabi-4_9-2014q4/bin:$PATH bash"

Notice that I have used double quotes (") instead of single ('), because I needed the value of the old PATH environment variable.

  • 1
    It worked! Could you also tell me what to do, if I would like the opened bash shell to execute (or, preferably, source) a shell script immediately after opening?
    – Multisync
    Feb 14, 2015 at 12:59
  • @Multisync, there might be a better way, but this is what I was able to find out right now. The "Invoking Bash" section of the manual suggests running it with the --init-file or --rcfile option. Since ~/.bashrc is going to be skipped, you might want to source it at the beginning of your script, so you don't miss it. So you would do something like --init-file custom.sh and at the beginning of custom.sh do source ~/.bashrc. Feb 14, 2015 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.