3

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.

Multisync
  • 280

1 Answers1

3

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.