josh.zsh-theme 1.12 KB
Newer Older
Josh Price's avatar
Josh Price committed
1
2
3
4
5
6
7
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%})"

8
function josh_prompt {
Josh Price's avatar
Josh Price committed
9
10
11
12
  (( spare_width = ${COLUMNS} ))
  prompt=" "

  branch=$(current_branch)
13
  ruby_version=$(rvm_prompt_info || rbenv_prompt_info)
Josh Price's avatar
Josh Price committed
14
15
16
  path_size=${#PWD}
  branch_size=${#branch}
  ruby_size=${#ruby_version}
17
  user_machine_size=${#${(%):-%n@%m-}}
Josh Price's avatar
Josh Price committed
18
19
20
21
22
23
24
25
26
27
  
  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
  
28
  (( spare_width = ${spare_width} - (${user_machine_size} + ${path_size} + ${branch_size} + ${ruby_size}) ))
Josh Price's avatar
Josh Price committed
29
30
31
32
33

  while [ ${#prompt} -lt $spare_width ]; do
    prompt=" $prompt"
  done
  
34
  prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(rvm_prompt_info || rbenv_prompt_info)%{$reset_color%} $(current_branch)"
Josh Price's avatar
Josh Price committed
35
36
37
38
39
40
41
  
  echo $prompt
}

setopt prompt_subst

PROMPT='
42
%n@%m $(josh_prompt)
Josh Price's avatar
Josh Price committed
43
%(?,%{%F{green}%},%{%F{red}%})⚡%{$reset_color%} '