A foreign environment interface for Fish shell
Some changes have been made since the original was last updated. Please see the Change log
Highlights of the changes compared to the original:
- Works with interactive commands
- Support for aliases
- Support un-setting variables
- Added
-voption (verbose) in addition to-d - Added
--testoption
Foreign environment wraps application execution in a way that environment variables and aliases that are exported or modified get imported back into fish. This makes possible running popular bash scripts, like the excellent nvm.
Using Oh My Fish:
omf install mnewt/foreign-envUsing Fisherman:
fisher mnewt/foreign-envIf 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>/functionsYou can use bash syntax to export variables:
fenv export PYTHON=python2This will have the same effect as typing:
set -g -x PYTHON python2You can also call multiple commands, separated by semicolon:
fenv source ~/.nvm/nvm.sh \; nvm --helpWhen 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"usage: fenv [-htv] <bash command>
-h, --help: Help - Print this help message
-t, --test: Test - Print the variables and aliases that would be
created, but make no changes
-v, --verbose: Verbose - Print the variables and aliases that are created
(-d also works)There are some more features I would like to add in the TODO file.
MIT © Original author Derek Willian Stavis