trapd00r.zsh-theme 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # trapd00r.zsh-theme
  2. #
  3. # This theme needs a terminal supporting 256 colors as well as unicode. It also
  4. # needs the script that splits up the current path and makes it fancy as located
  5. # here: https://github.com/trapd00r/utils/blob/master/zsh_path
  6. #
  7. # By default it spans over two lines like so:
  8. #
  9. # scp1@shiva:pts/9-> /home » scp1 (0)
  10. # >
  11. #
  12. # that's user@host:pts/-> splitted path (return status)
  13. #
  14. # If the current directory is a git repository, we span 3 lines;
  15. #
  16. # git❨ master ❩ DIRTY
  17. # scp1@shiva:pts/4-> /home » scp1 » dev » utils (0)
  18. # >
  19. autoload -U add-zsh-hook
  20. autoload -Uz vcs_info
  21. local c0=$( printf "\e[m")
  22. local c1=$( printf "\e[38;5;245m")
  23. local c2=$( printf "\e[38;5;250m")
  24. local c3=$( printf "\e[38;5;242m")
  25. local c4=$( printf "\e[38;5;197m")
  26. local c5=$( printf "\e[38;5;225m")
  27. local c6=$( printf "\e[38;5;240m")
  28. local c7=$( printf "\e[38;5;242m")
  29. local c8=$( printf "\e[38;5;244m")
  30. local c9=$( printf "\e[38;5;162m")
  31. local c10=$(printf "\e[1m")
  32. local c11=$(printf "\e[38;5;208m\e[1m")
  33. local c12=$(printf "\e[38;5;142m\e[1m")
  34. local c13=$(printf "\e[38;5;196m\e[1m")
  35. # We dont want to use the extended colorset in the TTY / VC.
  36. if [ "$TERM" = "linux" ]; then
  37. c1=$( printf "\e[34;1m")
  38. c2=$( printf "\e[35m")
  39. c3=$( printf "\e[31m")
  40. c4=$( printf "\e[31;1m")
  41. c5=$( printf "\e[32m")
  42. c6=$( printf "\e[32;1m")
  43. c7=$( printf "\e[33m")
  44. c8=$( printf "\e[33;1m")
  45. c9=$( printf "\e[34m")
  46. c11=$(printf "\e[35;1m")
  47. c12=$(printf "\e[36m")
  48. c13=$(printf "\e[31;1m")
  49. fi
  50. zstyle ':vcs_info:*' actionformats \
  51. '%{$c8%}(%f%s)%{$c7%}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
  52. zstyle ':vcs_info:*' formats \
  53. "%{$c8%}%s%%{$c7%}❨ %{$c9%}%{$c11%}%b%{$c7%} ❩%{$reset_color%}%f "
  54. zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
  55. zstyle ':vcs_info:*' enable git
  56. add-zsh-hook precmd prompt_jnrowe_precmd
  57. prompt_jnrowe_precmd () {
  58. vcs_info
  59. if [ "${vcs_info_msg_0_}" = "" ]; then
  60. dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
  61. PROMPT='%{$fg_bold[green]%}%p%{$reset_color%}${vcs_info_msg_0_}${dir_status} ${ret_status}%{$reset_color%}
  62. > '
  63. # modified, to be commited
  64. elif [[ $(git diff --cached --name-status 2>/dev/null ) != "" ]]; then
  65. dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
  66. PROMPT='${vcs_info_msg_0_}%{$30%} %{$bg_bold[red]%}%{$fg_bold[cyan]%}C%{$fg_bold[black]%}OMMIT%{$reset_color%}
  67. %{$fg_bold[green]%}%p%{$reset_color%}${dir_status}%{$reset_color%}
  68. > '
  69. elif [[ $(git diff --name-status 2>/dev/null ) != "" ]]; then
  70. dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
  71. PROMPT='${vcs_info_msg_0_}%{$bg_bold[red]%}%{$fg_bold[blue]%}D%{$fg_bold[black]%}IRTY%{$reset_color%}
  72. %{$fg_bold[green]%}%p%{$reset_color%}${dir_status}%{$reset_color%}
  73. %{$c13%}>%{$c0%} '
  74. else
  75. dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
  76. PROMPT='${vcs_info_msg_0_}
  77. %{$fg_bold[green]%}%p%{$reset_color%}${dir_status}%{$reset_color%}
  78. > '
  79. fi
  80. }
  81. # vim: set ft=zsh sw=2 et tw=0: