josh.zsh-theme 1.1 KB

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