mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-18 03:40:08 +00:00
style(rbenv): adapt to code style
This commit is contained in:
parent
5c14474eb2
commit
59cb231692
1 changed files with 46 additions and 46 deletions
|
@ -4,65 +4,65 @@
|
||||||
FOUND_RBENV=$+commands[rbenv]
|
FOUND_RBENV=$+commands[rbenv]
|
||||||
|
|
||||||
if [[ $FOUND_RBENV -ne 1 ]]; then
|
if [[ $FOUND_RBENV -ne 1 ]]; then
|
||||||
rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv" "/usr/local/opt/rbenv")
|
rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv" "/usr/local/opt/rbenv")
|
||||||
for dir in $rbenvdirs; do
|
for dir in $rbenvdirs; do
|
||||||
if [[ -d $dir/bin ]]; then
|
if [[ -d $dir/bin ]]; then
|
||||||
export PATH="$dir/bin:$PATH"
|
export PATH="$dir/bin:$PATH"
|
||||||
FOUND_RBENV=1
|
FOUND_RBENV=1
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $FOUND_RBENV -ne 1 ]]; then
|
if [[ $FOUND_RBENV -ne 1 ]]; then
|
||||||
if (( $+commands[brew] )) && dir=$(brew --prefix rbenv 2>/dev/null); then
|
if (( $+commands[brew] )) && dir=$(brew --prefix rbenv 2>/dev/null); then
|
||||||
if [[ -d $dir/bin ]]; then
|
if [[ -d $dir/bin ]]; then
|
||||||
export PATH="$dir/bin:$PATH"
|
export PATH="$dir/bin:$PATH"
|
||||||
FOUND_RBENV=1
|
FOUND_RBENV=1
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $FOUND_RBENV -eq 1 ]]; then
|
if [[ $FOUND_RBENV -eq 1 ]]; then
|
||||||
eval "$(rbenv init --no-rehash - zsh)"
|
eval "$(rbenv init --no-rehash - zsh)"
|
||||||
|
|
||||||
alias rubies="rbenv versions"
|
alias rubies="rbenv versions"
|
||||||
alias gemsets="rbenv gemset list"
|
alias gemsets="rbenv gemset list"
|
||||||
|
|
||||||
function current_ruby() {
|
function current_ruby() {
|
||||||
echo "$(rbenv version-name)"
|
echo "$(rbenv version-name)"
|
||||||
}
|
}
|
||||||
|
|
||||||
function current_gemset() {
|
function current_gemset() {
|
||||||
echo "$(rbenv gemset active 2>/dev/null)" | tr ' ' '+'
|
echo "$(rbenv gemset active 2>/dev/null)" | tr ' ' '+'
|
||||||
}
|
}
|
||||||
|
|
||||||
function gems() {
|
function gems() {
|
||||||
local rbenv_path=$(rbenv prefix)
|
local rbenv_path=$(rbenv prefix)
|
||||||
gem list $@ | sed -E \
|
gem list $@ | sed -E \
|
||||||
-e "s/\([0-9a-z, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
|
-e "s/\([0-9a-z, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
|
||||||
-e "s|$(echo $rbenv_path)|$fg[magenta]\$rbenv_path$reset_color|g" \
|
-e "s|$(echo $rbenv_path)|$fg[magenta]\$rbenv_path$reset_color|g" \
|
||||||
-e "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
|
-e "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
|
||||||
-e "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
|
-e "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
|
||||||
}
|
}
|
||||||
|
|
||||||
function rbenv_prompt_info() {
|
function rbenv_prompt_info() {
|
||||||
local ruby=$(current_ruby) gemset=$(current_gemset)
|
local ruby=$(current_ruby) gemset=$(current_gemset)
|
||||||
echo -n "${ZSH_THEME_RUBY_PROMPT_PREFIX}"
|
echo -n "${ZSH_THEME_RUBY_PROMPT_PREFIX}"
|
||||||
[[ -n "$gemset" ]] && echo -n "${ruby}@${gemset}" || echo -n "${ruby}"
|
[[ -n "$gemset" ]] && echo -n "${ruby}@${gemset}" || echo -n "${ruby}"
|
||||||
echo "${ZSH_THEME_RUBY_PROMPT_SUFFIX}"
|
echo "${ZSH_THEME_RUBY_PROMPT_SUFFIX}"
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
alias rubies="ruby -v"
|
alias rubies="ruby -v"
|
||||||
function gemsets() { echo "not supported" }
|
function gemsets() { echo "not supported" }
|
||||||
function current_ruby() { echo "not supported" }
|
function current_ruby() { echo "not supported" }
|
||||||
function current_gemset() { echo "not supported" }
|
function current_gemset() { echo "not supported" }
|
||||||
function gems() { echo "not supported" }
|
function gems() { echo "not supported" }
|
||||||
function rbenv_prompt_info() {
|
function rbenv_prompt_info() {
|
||||||
echo -n "${ZSH_THEME_RUBY_PROMPT_PREFIX}"
|
echo -n "${ZSH_THEME_RUBY_PROMPT_PREFIX}"
|
||||||
echo -n "system: $(ruby -v | cut -f-2 -d ' ')"
|
echo -n "system: $(ruby -v | cut -f-2 -d ' ')"
|
||||||
echo "${ZSH_THEME_RUBY_PROMPT_SUFFIX}"
|
echo "${ZSH_THEME_RUBY_PROMPT_SUFFIX}"
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unset FOUND_RBENV rbenvdirs dir
|
unset FOUND_RBENV rbenvdirs dir
|
||||||
|
|
Loading…
Reference in a new issue