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.

127 lines
3.2 KiB

3 years ago
  1. # oh-my-zsh Bureau Theme
  2. ### NVM
  3. ZSH_THEME_NVM_PROMPT_PREFIX="%B⬡%b "
  4. ZSH_THEME_NVM_PROMPT_SUFFIX=""
  5. ### Git [±master ▾●]
  6. ZSH_THEME_GIT_PROMPT_PREFIX="[%{$fg_bold[green]%}±%{$reset_color%}%{$fg_bold[white]%}"
  7. ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}]"
  8. ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}✓%{$reset_color%}"
  9. ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg[cyan]%}▴%{$reset_color%}"
  10. ZSH_THEME_GIT_PROMPT_BEHIND="%{$fg[magenta]%}▾%{$reset_color%}"
  11. ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_bold[green]%}●%{$reset_color%}"
  12. ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[yellow]%}●%{$reset_color%}"
  13. ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}"
  14. bureau_git_branch () {
  15. local ref
  16. ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
  17. ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
  18. echo "${ref#refs/heads/}"
  19. }
  20. bureau_git_status() {
  21. local result gitstatus
  22. # check status of files
  23. gitstatus=$(command git status --porcelain -b 2> /dev/null)
  24. if [[ -n "$gitstatus" ]]; then
  25. if $(echo "$gitstatus" | command grep -q '^[AMRD]. '); then
  26. result+="$ZSH_THEME_GIT_PROMPT_STAGED"
  27. fi
  28. if $(echo "$gitstatus" | command grep -q '^.[MTD] '); then
  29. result+="$ZSH_THEME_GIT_PROMPT_UNSTAGED"
  30. fi
  31. if $(echo "$gitstatus" | command grep -q -E '^\?\? '); then
  32. result+="$ZSH_THEME_GIT_PROMPT_UNTRACKED"
  33. fi
  34. if $(echo "$gitstatus" | command grep -q '^UU '); then
  35. result+="$ZSH_THEME_GIT_PROMPT_UNMERGED"
  36. fi
  37. else
  38. result+="$ZSH_THEME_GIT_PROMPT_CLEAN"
  39. fi
  40. # check status of local repository
  41. if $(echo "$gitstatus" | command grep -q '^## .*ahead'); then
  42. result+="$ZSH_THEME_GIT_PROMPT_AHEAD"
  43. fi
  44. if $(echo "$gitstatus" | command grep -q '^## .*behind'); then
  45. result+="$ZSH_THEME_GIT_PROMPT_BEHIND"
  46. fi
  47. if $(echo "$gitstatus" | command grep -q '^## .*diverged'); then
  48. result+="$ZSH_THEME_GIT_PROMPT_DIVERGED"
  49. fi
  50. if $(command git rev-parse --verify refs/stash &> /dev/null); then
  51. result+="$ZSH_THEME_GIT_PROMPT_STASHED"
  52. fi
  53. echo $result
  54. }
  55. bureau_git_prompt() {
  56. local gitbranch=$(bureau_git_branch)
  57. local gitstatus=$(bureau_git_status)
  58. local info
  59. if [[ -z "$gitbranch" ]]; then
  60. return
  61. fi
  62. info="${gitbranch:gs/%/%%}"
  63. if [[ -n "$gitstatus" ]]; then
  64. info+=" $gitstatus"
  65. fi
  66. echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${info}${ZSH_THEME_GIT_PROMPT_SUFFIX}"
  67. }
  68. _PATH="%{$fg_bold[white]%}%~%{$reset_color%}"
  69. if [[ $EUID -eq 0 ]]; then
  70. _USERNAME="%{$fg_bold[red]%}%n"
  71. _LIBERTY="%{$fg[red]%}#"
  72. else
  73. _USERNAME="%{$fg_bold[white]%}%n"
  74. _LIBERTY="%{$fg[green]%}$"
  75. fi
  76. _USERNAME="$_USERNAME%{$reset_color%}@%m"
  77. _LIBERTY="$_LIBERTY%{$reset_color%}"
  78. get_space () {
  79. local STR=$1$2
  80. local zero='%([BSUbfksu]|([FB]|){*})'
  81. local LENGTH=${#${(S%%)STR//$~zero/}}
  82. local SPACES=""
  83. (( LENGTH = ${COLUMNS} - $LENGTH - 1))
  84. for i in {0..$LENGTH}
  85. do
  86. SPACES="$SPACES "
  87. done
  88. echo $SPACES
  89. }
  90. _1LEFT="$_USERNAME $_PATH"
  91. _1RIGHT="[%*] "
  92. bureau_precmd () {
  93. _1SPACES=`get_space $_1LEFT $_1RIGHT`
  94. print
  95. print -rP "$_1LEFT$_1SPACES$_1RIGHT"
  96. }
  97. setopt prompt_subst
  98. PROMPT='> $_LIBERTY '
  99. RPROMPT='$(nvm_prompt_info) $(bureau_git_prompt)'
  100. autoload -U add-zsh-hook
  101. add-zsh-hook precmd bureau_precmd