Blame view
repos/robbyrussell/oh-my-zsh/plugins/chruby/chruby.plugin.zsh
2.23 KB
|
093a6c34b
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# # INSTRUCTIONS # # With either a manual or brew installed chruby things should just work. # # If you'd prefer to specify an explicit path to load chruby from # you can set variables like so: # # zstyle :omz:plugins:chruby path /local/path/to/chruby.sh # zstyle :omz:plugins:chruby auto /local/path/to/auto.sh # # TODO # - autodetermine correct source path on non OS X systems # - completion if ruby-install exists # rvm and rbenv plugins also provide this alias alias rubies='chruby' |
|
093a6c34b
|
18 19 20 21 22 |
_homebrew-installed() {
whence brew &> /dev/null
}
_chruby-from-homebrew-installed() {
|
|
ed37aae5b
|
23 |
[ -r $(brew --prefix chruby) ] &> /dev/null |
|
093a6c34b
|
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
}
_ruby-build_installed() {
whence ruby-build &> /dev/null
}
_ruby-install-installed() {
whence ruby-install &> /dev/null
}
# Simple definition completer for ruby-build
if _ruby-build_installed; then
_ruby-build() { compadd $(ruby-build --definitions) }
compdef _ruby-build ruby-build
fi
_source_from_omz_settings() {
|
|
271945d1f
|
41 42 43 |
local _chruby_path
local _chruby_auto
|
|
093a6c34b
|
44 45 |
zstyle -s :omz:plugins:chruby path _chruby_path
zstyle -s :omz:plugins:chruby auto _chruby_auto
|
|
ed37aae5b
|
46 |
if [[ -r ${_chruby_path} ]]; then
|
|
093a6c34b
|
47 48 |
source ${_chruby_path}
fi
|
|
ed37aae5b
|
49 |
if [[ -r ${_chruby_auto} ]]; then
|
|
093a6c34b
|
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
source ${_chruby_auto}
fi
}
_chruby_dirs() {
chrubydirs=($HOME/.rubies/ $PREFIX/opt/rubies)
for dir in chrubydirs; do
if [[ -d $dir ]]; then
RUBIES+=$dir
fi
done
}
if _homebrew-installed && _chruby-from-homebrew-installed ; then
source $(brew --prefix chruby)/share/chruby/chruby.sh
source $(brew --prefix chruby)/share/chruby/auto.sh
_chruby_dirs
elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then
source /usr/local/share/chruby/chruby.sh
source /usr/local/share/chruby/auto.sh
_chruby_dirs
else
_source_from_omz_settings
_chruby_dirs
fi
function ensure_chruby() {
$(whence chruby)
}
function current_ruby() {
local _ruby
_ruby="$(chruby |grep \* |tr -d '* ')"
if [[ $(chruby |grep -c \*) -eq 1 ]]; then
echo ${_ruby}
else
echo "system"
fi
}
function chruby_prompt_info() {
echo "$(current_ruby)"
}
# complete on installed rubies
_chruby() { compadd $(chruby | tr -d '* ') }
compdef _chruby chruby
|