Run foreign bash scripts and capture exported environment variables
Clone or download
edlanglois and sagebind Fix spurious SHLVL variable assignment by fenv. (#19)
Originally, the 2nd `env` call was made within one additional bash subshell
causing the SHLVL variable to differ and therefore be assigned by fenv.

In fish 3.0 this resulted in a warning message because SHLVL is read only.
Latest commit dddd921 Jan 16, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
functions Fix spurious SHLVL variable assignment by fenv. (#19) Jan 16, 2019
LICENSE Initial version. It runs nvm! 🍻 Aug 17, 2015 fix link in README Jan 29, 2017 README: Update caveats 🍺 Nov 1, 2015 README: Update caveats 🍺 Nov 1, 2015

Foreign Environment

A foreign environment interface for Fish shell

MIT License Fish Shell Version Oh My Fish Framework Travis Status

Foreign environment wraps application execution in a way that environment variables that are exported or modified get imported back into fish. This makes possible running popular bash scripts, like the excellent nvm.


Be sure to have Oh My Fish installed, so you just need to:

omf install foreign-env

If you dislike shell frameworks, you can still use Foreign Environment in Fish! Clone this repo somewhere and append to your ~/.config/fish/

set fish_function_path $fish_function_path <insert path to foreign-env repo>/functions

Usage examples

You can use bash syntax to export variables:

fenv export PYTHON=python2

This will have the same effect as typing:

set -g -x PYTHON python2

You can also call multiple commands, separated by semicolon:

fenv source ~/.nvm/ \; nvm --help

When commands aren't double quoted, you need to escape semicolon with slash \; to prevent fish from interpreting it. Or just quote the whole command:

fenv "source ~/.nvm/; nvm --help"


  • Currently we only handle environment variables that are added or modified. If a variable is unset (removed from environment) it will not be removed from fish.


MIT © Derek Willian Stavis