From 6ff0ddbfe3245043fb888c64d3425d7168c1695b Mon Sep 17 00:00:00 2001 From: Guangxiong Lin Date: Wed, 15 Nov 2023 20:16:31 +0800 Subject: Add rvm into fisher --- .config/fish/functions/rvm.fish | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .config/fish/functions/rvm.fish (limited to '.config/fish/functions/rvm.fish') 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 -- cgit v1.2.3