mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-02 02:19:06 +01:00
Rather than do our own searching, this gives the user full control of the PATH variable and of the search order for rbenv. It's also probably faster, since we let zsh do the searching for us.
37 lines
1,014 B
Bash
37 lines
1,014 B
Bash
if [[ $+commands[rbenv] -eq 1 ]] ; then
|
|
|
|
eval "$(rbenv init -)"
|
|
|
|
alias rubies="rbenv versions"
|
|
alias gemsets="rbenv gemset list"
|
|
|
|
function current_ruby() {
|
|
echo "$(rbenv version-name)"
|
|
}
|
|
|
|
function current_gemset() {
|
|
echo "$(rbenv gemset active 2&>/dev/null | sed -e ":a" -e '$ s/\n/+/gp;N;b a' | head -n1)"
|
|
}
|
|
|
|
function gems {
|
|
local rbenv_path=$(rbenv prefix)
|
|
gem list $@ | sed \
|
|
-Ee "s/\([0-9\.]+( .+)?\)/$fg[blue]&$reset_color/g" \
|
|
-Ee "s|$(echo $rbenv_path)|$fg[magenta]\$rbenv_path$reset_color|g" \
|
|
-Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
|
|
-Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
|
|
}
|
|
|
|
function rbenv_prompt_info() {
|
|
if [[ -n $(current_gemset) ]] ; then
|
|
echo "$(current_ruby)@$(current_gemset)"
|
|
else
|
|
echo "$(current_ruby)"
|
|
fi
|
|
}
|
|
|
|
else
|
|
alias rubies='ruby -v'
|
|
function gemsets() { echo 'not supported' }
|
|
function rbenv_prompt_info() { echo "system: $(ruby -v | cut -f-2 -d ' ')" }
|
|
fi
|