mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-22 13:50:09 +00:00
9f552130bd
Fixes #4085: core -> plugin dependency issue. Rename it to git_current_branch for clarity that it's git-specific. Update all plugins that were calling it to use new name. Fix variable leaks by making more variables in lib/git.zsh local. Have lib/git.zsh use [[ ]] instead of [ ] everywhere.
43 lines
1.1 KiB
Bash
43 lines
1.1 KiB
Bash
grey='\e[0;90m'
|
|
|
|
ZSH_THEME_GIT_PROMPT_PREFIX="%{$grey%}("
|
|
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
|
|
ZSH_THEME_GIT_PROMPT_DIRTY="%{$grey%}) %{$fg[yellow]%}✗%{$reset_color%}"
|
|
ZSH_THEME_GIT_PROMPT_CLEAN="%{$grey%})"
|
|
|
|
function josh_prompt {
|
|
(( spare_width = ${COLUMNS} ))
|
|
prompt=" "
|
|
|
|
branch=$(git_current_branch)
|
|
ruby_version=$(rvm_prompt_info || rbenv_prompt_info)
|
|
path_size=${#PWD}
|
|
branch_size=${#branch}
|
|
ruby_size=${#ruby_version}
|
|
user_machine_size=${#${(%):-%n@%m-}}
|
|
|
|
if [[ ${#branch} -eq 0 ]]
|
|
then (( ruby_size = ruby_size + 1 ))
|
|
else
|
|
(( branch_size = branch_size + 4 ))
|
|
if [[ -n $(git status -s 2> /dev/null) ]]; then
|
|
(( branch_size = branch_size + 2 ))
|
|
fi
|
|
fi
|
|
|
|
(( spare_width = ${spare_width} - (${user_machine_size} + ${path_size} + ${branch_size} + ${ruby_size}) ))
|
|
|
|
while [ ${#prompt} -lt $spare_width ]; do
|
|
prompt=" $prompt"
|
|
done
|
|
|
|
prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(rvm_prompt_info || rbenv_prompt_info)%{$reset_color%} $(git_current_branch)"
|
|
|
|
echo $prompt
|
|
}
|
|
|
|
setopt prompt_subst
|
|
|
|
PROMPT='
|
|
%n@%m $(josh_prompt)
|
|
%(?,%{%F{green}%},%{%F{red}%})⚡%{$reset_color%} '
|