diff options
author | Guangxiong Lin <[email protected]> | 2023-11-15 20:16:31 +0800 |
---|---|---|
committer | Guangxiong Lin <[email protected]> | 2023-11-15 20:16:31 +0800 |
commit | 6ff0ddbfe3245043fb888c64d3425d7168c1695b (patch) | |
tree | cfd705ed75aa6e11d0e513d4e68ef905020043e4 /.config/fish/functions/rvm.fish | |
parent | 134d43fcab5fab0ee642ef9aef9988dc1cc151ff (diff) | |
download | dotfiles-6ff0ddbfe3245043fb888c64d3425d7168c1695b.tar.gz dotfiles-6ff0ddbfe3245043fb888c64d3425d7168c1695b.tar.bz2 dotfiles-6ff0ddbfe3245043fb888c64d3425d7168c1695b.zip |
Add rvm into fisher
Diffstat (limited to '.config/fish/functions/rvm.fish')
-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 |