If I run fish from a bash prompt, it will inherit the environment variables I have set in my .bashrc and .profile files, including the important $PATH variable. So far so good.

Now, I want xfce4-terminal, my terminal emulator, to use fish instead of bash. I found that it supports a -e command line parameter for that but if I run xfce4-terminal -e fish from a GUI application launcher1 then I don't get the environment variables from bash. What gives?

1 Launching xfce4-terminal from an interactive bash prompt also didn't work but gnome-terminal, who has a similar command line switch did. However, gnome-terminal also didn't get the variables when launched from a GUI shortcut.

Edit: I've since bitten the bullet and just made fish into my login shell with chsh --shell /usr/bin/fish. Its much simpler than what I was trying to do before and it avoids some undesirable effects of running fish inside bash (such as having the $SHELL environment variable set to bash)


When bash is run as a non-interactive shell it will not source the .bashrc file and if you use a graphical display manager then the login shell used to run the GUI launcher commands might not have sourced the .profile file. Thus, commands run using the GUI launcher might not have the desired environment variables set when run.

A workaround I found was to tell the terminal emulator to run bash in interactive mode (with the -i flag) and then immediately run fish inside of it:

xfce4-terminal -e 'bash -i -c fish'
  • This took way to long to figure out so I guess I might as well write it down before I forget it. It also feels very hacky so I wonder if there is a better way to go at it... – hugomg Jan 14 '14 at 21:02

What happens when you launch from the GUI panel is child processes get the environment from that, and that does not normally source your bash interactive scripts. So the exported variables are not present in programs launched from the GUI.

What you can do is alter the the GUI startup script to source a new file that defines these variables.

What I do is put all the exported variables in a separate file that is sourced from the ~/.bash_profile, or ~/.zlogin (for zsh), that I call ~/.environ.

Example entries in this file:

export SSH_ASKPASS=/usr/bin/x11-ssh-askpass

For the GUI, now you have to modify that startup script.

Xfce will prefer your personal xinitrc, so first do this:

cp /etc/xdg/xfce4/xinitrc ~/.config/xfce4/xinitrc

Then edit this copy and add this line:

source $HOME/.environ

I add it just before the xfce4-session start line. Now the GUI launcher will have the same exported variables as any shell. Anything launched from it will inherit them, as if launched from a shell session.


Exclude reading config files

I believe you could also do this using just /bin/sh instead or even bash without any configuration files being read.


$ xfce4-terminal -e '/bin/sh -c fish'
$ xfce4-terminal -e 'bash -norc -c fish'

Include reading config files

If you're aim is to get Bash to read these variables and then launch fish you can change the switching slightly.

$ xfce4-terminal -e '/bin/sh -i -c fish'

Or use the technique that you mentioned in your answer.

$ xfce4-terminal -e 'bash -i -c fish'

Debugging tip

You can also debug what's going on by using strace to see what files are being read when you invoke your shells inside xfce4's terminal.

$ xfce4-terminal -e 'strace -o strace.log /bin/sh -c fish'

If you grep through the resulting strace.log file you shouldn't see any mention of the configuration files you're trying to avoid reading.

  • Well, I'm actually trying to read the configurations instead of avoiding them so your suggestions are a bit backwards. But using strace for debugging was not something that had crossed my mind. – hugomg Jan 14 '14 at 23:05
  • @missingno - sorry about that, I mis-read what you were asking in the 1st paragraph. I added the opposing method, which is similar to yours, but using /bin/sh. Also added your method only for completeness and linked to your A, so you don't think I'm trying to steal your thunder. Am only trying to provide a more exhaustive A. 8-) – slm Jan 14 '14 at 23:19


Exec=bash -i -c "/home/mozes/dev/sqldeveloper/sqldeveloper.sh"


" -i If the -i option is present, the shell is interactive."

Example XFCE launcher relying on environment variables from


to provide info for SQLDeveloper so that it can find the TNS Listener aliases at tnsnames.ora

ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME

XFCE launcher:

[Desktop Entry]
Name=Oracle SQLDeveloper
Exec=bash -i -c "/home/mozes/dev/sqldeveloper/sqldeveloper.sh"

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.