aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2023-11-15 20:16:31 +0800
committerGuangxiong Lin <[email protected]>2023-11-15 20:16:31 +0800
commit6ff0ddbfe3245043fb888c64d3425d7168c1695b (patch)
treecfd705ed75aa6e11d0e513d4e68ef905020043e4
parent134d43fcab5fab0ee642ef9aef9988dc1cc151ff (diff)
downloaddotfiles-6ff0ddbfe3245043fb888c64d3425d7168c1695b.tar.gz
dotfiles-6ff0ddbfe3245043fb888c64d3425d7168c1695b.tar.bz2
dotfiles-6ff0ddbfe3245043fb888c64d3425d7168c1695b.zip
Add rvm into fisher
-rw-r--r--.config/fish/conf.d/rvm.fish31
-rw-r--r--.config/fish/fish_plugins1
-rw-r--r--.config/fish/fish_variables3
-rw-r--r--.config/fish/functions/rvm.fish19
4 files changed, 53 insertions, 1 deletions
diff --git a/.config/fish/conf.d/rvm.fish b/.config/fish/conf.d/rvm.fish
new file mode 100644
index 0000000..0b00091
--- /dev/null
+++ b/.config/fish/conf.d/rvm.fish
@@ -0,0 +1,31 @@
+rvm current 1>/dev/null 2>&1
+
+function __check_rvm --on-variable PWD -d 'Setup rvm on directory change'
+ status --is-command-substitution; and return
+ if test "$rvm_project_rvmrc" != 0
+ set -l cwd $PWD
+ while true
+ if contains $cwd "" $HOME "/"
+ if test "$rvm_project_rvmrc_default" = 1
+ rvm default 1>/dev/null 2>&1
+ end
+ break
+ else
+ if begin
+ test -s ".rvmrc"
+ or test -s ".ruby-version"
+ or test -s ".ruby-gemset"
+ or test -s ".versions.conf"
+ or test -s "Gemfile"
+ end
+ rvm reload 1> /dev/null 2>&1
+ rvm rvmrc load 1>/dev/null 2>&1
+ break
+ else
+ set cwd (dirname "$cwd")
+ end
+ end
+ end
+ set -e cwd
+ end
+end
diff --git a/.config/fish/fish_plugins b/.config/fish/fish_plugins
index 9673b42..986ddc0 100644
--- a/.config/fish/fish_plugins
+++ b/.config/fish/fish_plugins
@@ -1,2 +1,3 @@
jorgebucaran/fisher
jorgebucaran/nvm.fish
+oh-my-fish/plugin-rvm
diff --git a/.config/fish/fish_variables b/.config/fish/fish_variables
index 2e064e3..def1a29 100644
--- a/.config/fish/fish_variables
+++ b/.config/fish/fish_variables
@@ -3,7 +3,8 @@
SETUVAR __fish_initialized:3400
SETUVAR _fisher_jorgebucaran_2F_fisher_files:\x7e/\x2econfig/fish/functions/fisher\x2efish\x1e\x7e/\x2econfig/fish/completions/fisher\x2efish
SETUVAR _fisher_jorgebucaran_2F_nvm_2E_fish_files:\x7e/\x2econfig/fish/functions/_nvm_index_update\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_list\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_version_activate\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_version_deactivate\x2efish\x1e\x7e/\x2econfig/fish/functions/nvm\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/nvm\x2efish\x1e\x7e/\x2econfig/fish/completions/nvm\x2efish
-SETUVAR _fisher_plugins:jorgebucaran/fisher\x1ejorgebucaran/nvm\x2efish
+SETUVAR _fisher_oh_2D_my_2D_fish_2F_plugin_2D_rvm_files:\x7e/\x2econfig/fish/functions/rvm\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/rvm\x2efish
+SETUVAR _fisher_plugins:jorgebucaran/fisher\x1ejorgebucaran/nvm\x2efish\x1eoh\x2dmy\x2dfish/plugin\x2drvm
SETUVAR _fisher_upgraded_to_4_4:\x1d
SETUVAR fish_color_autosuggestion:555\x1ebrblack
SETUVAR fish_color_cancel:\x2dr
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