irongit
dotfiles/oh-my-zsh/themes/josh.zsh-theme
43 lines1.1 KB
1grey='\e[0;90m'
2
3ZSH_THEME_GIT_PROMPT_PREFIX="%{$grey%}("
4ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
5ZSH_THEME_GIT_PROMPT_DIRTY="%{$grey%}) %{$fg[yellow]%}✗%{$reset_color%}"
6ZSH_THEME_GIT_PROMPT_CLEAN="%{$grey%})"
7
8function josh_prompt {
9 (( spare_width = ${COLUMNS} ))
10 prompt=" "
11
12 branch=$(git_current_branch)
13 ruby_version=$(ruby_prompt_info)
14 path_size=${#PWD}
15 branch_size=${#branch}
16 ruby_size=${#ruby_version}
17 user_machine_size=${#${(%):-%n@%m-}}
18
19 if [[ ${#branch} -eq 0 ]]
20 then (( ruby_size = ruby_size + 1 ))
21 else
22 (( branch_size = branch_size + 4 ))
23 if [[ -n $(git status -s 2> /dev/null) ]]; then
24 (( branch_size = branch_size + 2 ))
25 fi
26 fi
27
28 (( spare_width = ${spare_width} - (${user_machine_size} + ${path_size} + ${branch_size} + ${ruby_size}) ))
29
30 while [ ${#prompt} -lt $spare_width ]; do
31 prompt=" $prompt"
32 done
33
34 prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(ruby_prompt_info)%{$reset_color%} $(git_current_branch)"
35
36 echo $prompt
37}
38
39setopt prompt_subst
40
41PROMPT='
42%n@%m $(josh_prompt)
43%(?,%{%F{green}%},%{%F{red}%})⚡%{$reset_color%} '