mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-25 01:03:41 +01:00
299cd4777a
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.
44 lines
937 B
Bash
44 lines
937 B
Bash
# Based on bira theme
|
||
|
||
setopt prompt_subst
|
||
|
||
() {
|
||
|
||
local PR_USER PR_USER_OP PR_PROMPT PR_HOST
|
||
|
||
# Check the UID
|
||
if [[ $UID -ne 0 ]]; then # normal user
|
||
PR_USER='%F{green}%n%f'
|
||
PR_USER_OP='%F{green}%#%f'
|
||
PR_PROMPT='%f➤ %f'
|
||
else # root
|
||
PR_USER='%F{red}%n%f'
|
||
PR_USER_OP='%F{red}%#%f'
|
||
PR_PROMPT='%F{red}➤ %f'
|
||
fi
|
||
|
||
# Check if we are on SSH or not
|
||
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
|
||
PR_HOST='%F{red}%M%f' # SSH
|
||
else
|
||
PR_HOST='%F{green}%M%f' # no SSH
|
||
fi
|
||
|
||
|
||
local return_code="%(?..%F{red}%? ↵%f)"
|
||
|
||
local user_host="${PR_USER}%F{cyan}@${PR_HOST}"
|
||
local current_dir="%B%F{blue}%~%f%b"
|
||
local git_branch='$(git_prompt_info)'
|
||
|
||
PROMPT="╭─${user_host} ${current_dir} \$(ruby_prompt_info) ${git_branch}
|
||
╰─$PR_PROMPT "
|
||
RPROMPT="${return_code}"
|
||
|
||
ZSH_THEME_GIT_PROMPT_PREFIX="%F{yellow}‹"
|
||
ZSH_THEME_GIT_PROMPT_SUFFIX="› %f"
|
||
ZSH_THEME_RUBY_PROMPT_PREFIX="%F{red}‹"
|
||
ZSH_THEME_RUBY_PROMPT_SUFFIX="›%f"
|
||
|
||
}
|