mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-04-03 04:20:01 +02:00
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: /Users/username/.rvm/bin/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
1.1 KiB
Bash
44 lines
1.1 KiB
Bash
#
|
|
# Based on Geoffrey Grosenbach's peepcode zsh theme from
|
|
# https://github.com/topfunky/zsh-simple
|
|
#
|
|
|
|
git_repo_path() {
|
|
git rev-parse --git-dir 2>/dev/null
|
|
}
|
|
|
|
git_commit_id() {
|
|
git rev-parse --short HEAD 2>/dev/null
|
|
}
|
|
|
|
git_mode() {
|
|
if [[ -e "$repo_path/BISECT_LOG" ]]; then
|
|
echo "+bisect"
|
|
elif [[ -e "$repo_path/MERGE_HEAD" ]]; then
|
|
echo "+merge"
|
|
elif [[ -e "$repo_path/rebase" || -e "$repo_path/rebase-apply" || -e "$repo_path/rebase-merge" || -e "$repo_path/../.dotest" ]]; then
|
|
echo "+rebase"
|
|
fi
|
|
}
|
|
|
|
git_dirty() {
|
|
if [[ "$repo_path" != '.' && `git ls-files -m` != "" ]]; then
|
|
echo " %{$fg_bold[grey]%}✗%{$reset_color%}"
|
|
fi
|
|
}
|
|
|
|
git_prompt() {
|
|
local cb=$(current_branch)
|
|
if [ -n "$cb" ]; then
|
|
local repo_path=$(git_repo_path)
|
|
echo " %{$fg_bold[grey]%}$cb %{$fg[white]%}$(git_commit_id)%{$reset_color%}$(git_mode)$(git_dirty)"
|
|
fi
|
|
}
|
|
|
|
local smiley="%(?,%{$fg[green]%}☺%{$reset_color%},%{$fg[red]%}☹%{$reset_color%})"
|
|
|
|
PROMPT='
|
|
%~
|
|
${smiley} %{$reset_color%}'
|
|
|
|
RPROMPT='%{$fg[white]%} $(ruby_prompt_info)$(git_prompt)%{$reset_color%}'
|