my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
3.6 KiB

3 years ago
  1. # trapd00r.zsh-theme
  2. #
  3. # This theme needs a terminal supporting 256 colors as well as unicode.
  4. # In order to avoid external dependencies, it also has a zsh version of
  5. # the previously used perl script https://github.com/trapd00r/utils/blob/master/zsh_path,
  6. # which splits up the current path and makes it fancy.
  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=$'\e[m'
  23. local c1=$'\e[38;5;245m'
  24. local c2=$'\e[38;5;250m'
  25. local c3=$'\e[38;5;242m'
  26. local c4=$'\e[38;5;197m'
  27. local c5=$'\e[38;5;225m'
  28. local c6=$'\e[38;5;240m'
  29. local c7=$'\e[38;5;242m'
  30. local c8=$'\e[38;5;244m'
  31. local c9=$'\e[38;5;162m'
  32. local c10=$'\e[1m'
  33. local c11=$'\e[38;5;208m\e[1m'
  34. local c12=$'\e[38;5;142m\e[1m'
  35. local c13=$'\e[38;5;196m\e[1m'
  36. zsh_path() {
  37. setopt localoptions nopromptsubst
  38. local colors
  39. colors=$(echoti colors)
  40. local -A yellow
  41. yellow=(
  42. 1 '%F{228}' 2 '%F{222}' 3 '%F{192}' 4 '%F{186}'
  43. 5 '%F{227}' 6 '%F{221}' 7 '%F{191}' 8 '%F{185}'
  44. 9 '%F{226}' 10 '%F{220}' 11 '%F{190}' 12 '%F{184}'
  45. 13 '%F{214}' 14 '%F{178}' 15 '%F{208}' 16 '%F{172}'
  46. 17 '%F{202}' 18 '%F{166}'
  47. )
  48. local dir i=1
  49. for dir (${(s:/:)PWD}); do
  50. if [[ $i -eq 1 ]]; then
  51. if [[ $colors -ge 256 ]]; then
  52. print -Pn "%F{065}%B /%b"
  53. else
  54. print -Pn "\e[31;1m /"
  55. fi
  56. else
  57. if [[ $colors -ge 256 ]]; then
  58. print -Pn "${yellow[$i]:-%f} » "
  59. else
  60. print -Pn "%F{yellow} > "
  61. fi
  62. fi
  63. (( i++ ))
  64. if [[ $colors -ge 256 ]]; then
  65. print -Pn "%F{065}$dir"
  66. else
  67. print -Pn "%F{blue}$dir"
  68. fi
  69. done
  70. print -Pn "%f"
  71. }
  72. # We don't want to use the extended colorset in the TTY / VC.
  73. if [ "$TERM" = linux ]; then
  74. c1=$'\e[34;1m'
  75. c2=$'\e[35m'
  76. c3=$'\e[31m'
  77. c4=$'\e[31;1m'
  78. c5=$'\e[32m'
  79. c6=$'\e[32;1m'
  80. c7=$'\e[33m'
  81. c8=$'\e[33;1m'
  82. c9=$'\e[34m'
  83. c11=$'\e[35;1m'
  84. c12=$'\e[36m'
  85. c13=$'\e[31;1m'
  86. fi
  87. zstyle ':vcs_info:*' actionformats \
  88. '%{$c8%}(%f%s)%{$c7%}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
  89. zstyle ':vcs_info:*' formats \
  90. "%{$c8%}%s%%{$c7%}❨ %{$c9%}%{$c11%}%b%{$c7%} ❩%{$reset_color%}%f "
  91. zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
  92. zstyle ':vcs_info:*' enable git
  93. add-zsh-hook precmd prompt_jnrowe_precmd
  94. prompt_jnrowe_precmd () {
  95. vcs_info
  96. if [ "${vcs_info_msg_0_}" = "" ]; then
  97. dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
  98. PROMPT='${dir_status} ${ret_status}%{$reset_color%}
  99. > '
  100. # modified, to be committed
  101. elif [[ $(git diff --cached --name-status 2>/dev/null ) != "" ]]; then
  102. dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
  103. PROMPT='${vcs_info_msg_0_}%{$30%} %{$bg_bold[red]%}%{$fg_bold[cyan]%}C%{$fg_bold[black]%}OMMIT%{$reset_color%}
  104. ${dir_status}%{$reset_color%}
  105. > '
  106. elif [[ $(git diff --name-status 2>/dev/null ) != "" ]]; then
  107. dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
  108. PROMPT='${vcs_info_msg_0_}%{$bg_bold[red]%}%{$fg_bold[blue]%}D%{$fg_bold[black]%}IRTY%{$reset_color%}
  109. ${dir_status}%{$reset_color%}
  110. %{$c13%}>%{$c0%} '
  111. else
  112. dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
  113. PROMPT='${vcs_info_msg_0_}
  114. ${dir_status}%{$reset_color%}
  115. > '
  116. fi
  117. }