Themes: switch to using ruby_prompt_info()
Changes themes displaying RVM or other Ruby version info to use the central ruby_prompt_info function. This supports more Ruby versioning mechanisms, reduces copy-and-paste code, and avoids "zsh: no such file or directory: rvm-prompt" when run on machines that do not have RVM installed. Changes the prefix/suffix variable names to ZSH_THEME_RUBY_PROMPT_PREFIX and ZSH_THEME_RUBY_PROMPT_SUFFIX, since they apply to all Ruby versioning mechanisms, not just RVM. Allows empty ZSH_THEME_RUBY_PROMPT_PREFIX and ZSH_THEME_RUBY_PROMPT_SUFFIX.
This commit is contained in:
committed by
Marc Cornellà
parent
ea3e666e04
commit
299cd4777a
@@ -8,20 +8,7 @@ function virtualenv_info {
|
||||
[[ -n "$VIRTUAL_ENV" ]] && echo '('${VIRTUAL_ENV:t}') '
|
||||
}
|
||||
|
||||
function ruby_prompt {
|
||||
if (( $+commands[rvm-prompt] )); then
|
||||
print -n $ZSH_THEME_RUBY_PROMPT_PREFIX
|
||||
print -n $(~/.rvm/bin/rvm-prompt)
|
||||
print -n $ZSH_THEME_RUBY_PROMPT_SUFFIX
|
||||
elif (( $+commands[rbenv] )); then
|
||||
print -n $ZSH_THEME_RUBY_PROMPT_PREFIX
|
||||
print -n $(rbenv version | sed -e "s/ (set.*$//")
|
||||
print -n $ZSH_THEME_RUBY_PROMPT_SUFFIX
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
PROMPT='%F{magenta}%n%f at %F{yellow}%m%f in %B%F{green}%~%f%b$(git_prompt_info)$(ruby_prompt)
|
||||
PROMPT='%F{magenta}%n%f at %F{yellow}%m%f in %B%F{green}%~%f%b$(git_prompt_info)$(ruby_prompt_info)
|
||||
$(virtualenv_info) $(prompt_char) '
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX=' on %F{magenta}'
|
||||
|
||||
Reference in New Issue
Block a user