Parent directory

josh.zsh-theme

1120 bytes
 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  branch="${branch//\%/%%}"
14  ruby_version=$(ruby_prompt_info)
15  path_size=${#PWD}
16  branch_size=${#branch}
17  ruby_size=${#ruby_version}
18  user_machine_size=${#${(%):-%n@%m-}}
19
20  if [[ ${#branch} -eq 0 ]]
21    then (( ruby_size = ruby_size + 1 ))
22  else
23    (( branch_size = branch_size + 4 ))
24    if [[ -n $(git status -s 2> /dev/null) ]]; then
25      (( branch_size = branch_size + 2 ))
26    fi
27  fi
28
29  (( spare_width = ${spare_width} - (${user_machine_size} + ${path_size} + ${branch_size} + ${ruby_size}) ))
30
31  while [ ${#prompt} -lt $spare_width ]; do
32    prompt=" $prompt"
33  done
34
35  prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(ruby_prompt_info)%{$reset_color%} ${branch}"
36
37  echo $prompt
38}
39
40setopt prompt_subst
41
42PROMPT='
43%n@%m $(josh_prompt)
44%(?,%{%F{green}%},%{%F{red}%})⚡%{$reset_color%} '