bixel.zsh-theme 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # vim:ft=zsh ts=2 sw=2 sts=2
  2. # first approach to simple template using some functions from agnoster theme
  3. # Git: branch/detached head, dirty status
  4. prompt_git() {
  5. local ref dirty mode repo_path
  6. repo_path=$(git rev-parse --git-dir 2>/dev/null)
  7. if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
  8. dirty=$(parse_git_dirty)
  9. ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)"
  10. if [[ -n $dirty ]]; then
  11. prompt_segment yellow black
  12. else
  13. prompt_segment green black
  14. fi
  15. if [[ -e "${repo_path}/BISECT_LOG" ]]; then
  16. mode=" <B>"
  17. elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then
  18. mode=" >M<"
  19. elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then
  20. mode=" >R>"
  21. fi
  22. setopt promptsubst
  23. autoload -Uz vcs_info
  24. zstyle ':vcs_info:*' enable git
  25. zstyle ':vcs_info:*' get-revision true
  26. zstyle ':vcs_info:*' check-for-changes true
  27. zstyle ':vcs_info:*' stagedstr '✚'
  28. zstyle ':vcs_info:git:*' unstagedstr '●'
  29. zstyle ':vcs_info:*' formats ' %u%c'
  30. zstyle ':vcs_info:*' actionformats ' %u%c'
  31. vcs_info
  32. echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_%% }${mode}"
  33. fi
  34. }
  35. PROMPT='[%~] '
  36. RPROMPT='[$(prompt_git)]'