diff options
Diffstat (limited to '.config/fish/functions')
-rw-r--r-- | .config/fish/functions/rvm.fish | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/.config/fish/functions/rvm.fish b/.config/fish/functions/rvm.fish new file mode 100644 index 0000000..a186cae --- /dev/null +++ b/.config/fish/functions/rvm.fish @@ -0,0 +1,19 @@ +function rvm -d 'Ruby enVironment Manager' + # run RVM and capture the resulting environment + set -l env_file (mktemp -t rvm.fish.XXXXXXXXXX) + + bash -c '[ -e ~/.rvm/scripts/rvm ] && source ~/.rvm/scripts/rvm || \ + source /usr/local/rvm/scripts/rvm; rvm "$@"; status=$?; \ + env > "$0"; exit $status' $env_file $argv + + # grep the rvm_* *PATH RUBY_* GEM_* variables from the captured environment + # exclude lines with _clr and _debug + # apply rvm_* *PATH RUBY_* GEM_* variables from the captured environment + and grep '^rvm\|^[^=]*PATH\|^RUBY_\|^GEM_' $env_file | \ + grep -v _clr | grep -v _debug | \ + sed '/^PATH/y/:/ /; s/^/set -xg /; s/=/ /; s/$/ ;/; s/(//; s/)//' | \ + source + + # clean up + rm -f $env_file +end |