First of all, I'm on OSX10. My default shell is BASH, which I have set up (through .profile and .bashrc) to automatically run the FISH shell when I open my terminal emulator. This allows me to set up variables etc. in BASH before I load up FISH.

Sometimes, however, I want to run scripts which are written for BASH, from my FISH shell. This is necessary because FISH isn't syntactically compatible with BASH. When typing 'bash' in my FISH, the BASH I open automatically opens another FISH on top of itself, because of my .profile/.bashrc. That makes it all fishy (pun intended), because I then have to exit the top FISH to get into the BASH on top of the second FISH.

My question is: I know BASH can be loaded up as a login shell (executing .profile), and a non-login shell (executing .bashrc). Would it be possible to add a third 'context', which I can set up to load when BASH is run from inside FISH? That would solve the double-FISH problem because I'd be able not to load either .bashrc or .profile.

I hope you understand my question -- thanks in advance for answers!

  • duplicate: unix.stackexchange.com/q/183801/4667 Feb 9, 2015 at 14:14
  • 1
    I highly recommend you fully embrace your shell choice and change your login shell to fish using chsh -s /usr/local/bin/fish (or wherever you have fish installed. Also, you may need to add fish to the list of known shells in /etc/shells). Learn to set up variables in fish and stop using bash as a crutch.
    – Spiff
    Feb 9, 2015 at 17:44

1 Answer 1


If you want to run scripts from your fish shell, there is no need to add a third context, all you need to do is run bash myscript.sh.

From the bash man page:

    The personal initialization file, executed for login shells
    The individual per-interactive-shell startup file

If you neither invoke a login shell bash -l or an interactive shell bash but instead use a script as the argument, there neither file is loaded.

For example, if the file test.sh contains

function bashtest {
    echo "test"

If I execute it using bash it runs correctly using bash as an interpreter.

Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
$user@host ~> bash test.sh
$user@host ~> 

If you want to type a bash command directly then you can pipe your command to bash like so:

$user@host ~> echo "function bashtest { echo test; }; bashtest" | bash
$user@host ~> 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .