oh-my-fish/plugin-foreign-env

Run foreign bash scripts and capture exported environment variables

Shell

252

37 commits

updated Jul 6, 2026

See the code

README

Foreign Environment

A foreign environment interface for Fish shell

MIT License Fish Shell Version Oh My Fish Framework test


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.

Install

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/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.sh \; 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.sh; nvm --help"

Caveats

  • 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.

License

MIT © Derek Willian Stavis

Significant stargazers

Yuyi Wang

405 followers · starred Jun 2022

Dmitry Kalinkin

38 followers · starred Mar 2017

Basil Sh.

103 followers · starred Dec 2022

Florian Jacob

39 followers · starred Mar 2017

oh-my-fish/plugin-foreign-env

Run foreign bash scripts and capture exported environment variables

Shell

252

37 commits

updated Jul 6, 2026

See the code

README

Foreign Environment

A foreign environment interface for Fish shell

MIT License Fish Shell Version Oh My Fish Framework test


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.

Install

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/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.sh \; 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.sh; nvm --help"

Caveats

  • 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.

License

MIT © Derek Willian Stavis

Significant stargazers

Yuyi Wang

405 followers · starred Jun 2022

Dmitry Kalinkin

38 followers · starred Mar 2017

Basil Sh.

103 followers · starred Dec 2022

Florian Jacob

39 followers · starred Mar 2017

Languages

Shell

100.0%