trapd00r.zsh-theme 3.2 KB

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