gitster.zsh-theme 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # vim:et sts=2 sw=2 ft=zsh
  2. #
  3. # Gitster theme
  4. # https://github.com/shashankmehta/dotfiles/blob/master/thesetup/zsh/.oh-my-zsh/custom/themes/gitster.zsh-theme
  5. #
  6. # Requires the `git-info` zmodule to be included in the .zimrc file.
  7. prompt_gitster_pwd() {
  8. prompt_short_dir=$(short_pwd)
  9. git_root=$(command git rev-parse --show-toplevel 2> /dev/null) && prompt_short_dir=${prompt_short_dir#${$(short_pwd $git_root):h}/}
  10. print -n "%F{white}${prompt_short_dir}"
  11. }
  12. prompt_gitster_git() {
  13. [[ -n ${git_info} ]] && print -n "${(e)git_info[prompt]}"
  14. }
  15. prompt_gitster_precmd() {
  16. (( ${+functions[git-info]} )) && git-info
  17. }
  18. prompt_gitster_setup() {
  19. local prompt_gitster_status='%(?:%F{green}:%F{red})➜ '
  20. autoload -Uz add-zsh-hook && add-zsh-hook precmd prompt_gitster_precmd
  21. prompt_opts=(cr percent sp subst)
  22. zstyle ':zim:git-info:branch' format '%b'
  23. zstyle ':zim:git-info:commit' format '%c'
  24. zstyle ':zim:git-info:clean' format '%F{green}✓'
  25. zstyle ':zim:git-info:dirty' format '%F{yellow}✗'
  26. zstyle ':zim:git-info:keys' format \
  27. 'prompt' ' %F{cyan}%b%c %C%D'
  28. PS1="${prompt_gitster_status}\$(prompt_gitster_pwd)\$(prompt_gitster_git)%f "
  29. RPS1=''
  30. }
  31. prompt_gitster_setup "${@}"