Skip to content
Run bash utilities, replaying environment changes in fish without leaving the comfort of your session
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
test Initial commit Feb 21, 2019
.travis.yml Initial commit Feb 21, 2019 Initial commit Feb 21, 2019 Use console code block Feb 23, 2019 Initial commit Feb 21, 2019


Build Status Releases

Bax is a POSIX shell execution wrapper for the fish shell. Use it to run bash utilities, replaying environment changes in fish without leaving the comfort of your session.


Install with Fisher (recommended):

fisher add jorgebucaran/fish-bax
Not using a package manager?

Copy to any directory on your function path.

set -q XDG_CONFIG_HOME; or set XDG_CONFIG_HOME ~/.config
curl --create-dirs -sLo $XDG_CONFIG_HOME/fish/functions/

To uninstall, remove the file.

System Requirements


You need to run a script in bash and want to preserve changes in the environment, e.g., modifications to the $PATH, exported and unset variables, and so on. What do you do? Nuke the current session.

$ exec bash -c "$commands; exec fish"

This is not a rare pattern. Fork a POSIX shell, run your scripts there, inherit the environment in fish. And if you're content with that, you're all set, grab it and off you go. Any caveats? Unfortunately, yes.

For starters, there's no way to preserve the last command exit status in the new shell. You'll lose the entire state of your session; history may not sync up correctly if you have fish running in other terminal tabs, local variables are gone. Fish takes a little while to start up. Moreover, things fish is configured to do on startup like running configuration snippets or displaying a custom greeting, may not be appreciated. If jobs are running in the background, they'll be terminated too.

To solve this problem, we run your commands in bash, capture the environment changes and reproduce them in fish, so you don't have to exec-away your session. Now you can have your cake and eat it too.


Use bax followed by the bash commands you want to run.

$ bax export PYTHON=python2

That will set the environment variable PYTHON in your session.

$ env | string match "PYTHON=*"

Use double quotes (or single quotes to avoid variable substitution) to enclose multiple commands separated by a semicolon. Here's an example that downloads the latest Node.js release using creationix/nvm.

$ bax "source ~/.nvm/ --no-use; nvm use latest"

Changing the current directory in a subshell leaves you back where you were when you exit. Bax switches directories instead. To move backward through the directory history use cd - or prevd as you usually would.

$ bax cd ~
$ pwd

Bax supports bash aliases too. While it's unrealistic to handle every possible way of defining an alias, typical cases like command shortcuts work out of the box.

$ bax alias g=git
$ g init
Initialized empty Git repository in ~/Code/fish-bax/.git/

Bax is not infallible. Interactive utilities, such as ssh-add are not currently supported.



You can’t perform that action at this time.