avit.zsh-theme 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # AVIT ZSH Theme
  2. PROMPT='
  3. $(_user_host)${_current_dir} $(git_prompt_info) $(_ruby_version)
  4. %{$fg[$CARETCOLOR]%}▶%{$resetcolor%} '
  5. PROMPT2='%{$fg[$CARETCOLOR]%}◀%{$reset_color%} '
  6. RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
  7. local _current_dir="%{$fg_bold[blue]%}%3~%{$reset_color%} "
  8. local _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}"
  9. local _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
  10. function _current_dir() {
  11. local _max_pwd_length="65"
  12. if [[ $(echo -n $PWD | wc -c) -gt ${_max_pwd_length} ]]; then
  13. echo "%{$fg_bold[blue]%}%-2~ ... %3~%{$reset_color%} "
  14. else
  15. echo "%{$fg_bold[blue]%}%~%{$reset_color%} "
  16. fi
  17. }
  18. function _user_host() {
  19. if [[ -n $SSH_CONNECTION ]]; then
  20. me="%n@%m"
  21. elif [[ $LOGNAME != $USER ]]; then
  22. me="%n"
  23. fi
  24. if [[ -n $me ]]; then
  25. echo "%{$fg[cyan]%}$me%{$reset_color%}:"
  26. fi
  27. }
  28. function _vi_status() {
  29. if {echo $fpath | grep -q "plugins/vi-mode"}; then
  30. echo "$(vi_mode_prompt_info)"
  31. fi
  32. }
  33. function _ruby_version() {
  34. if {echo $fpath | grep -q "plugins/rvm"}; then
  35. echo "%{$fg[grey]%}$(rvm_prompt_info)%{$reset_color%}"
  36. elif {echo $fpath | grep -q "plugins/rbenv"}; then
  37. echo "%{$fg[grey]%}$(rbenv_prompt_info)%{$reset_color%}"
  38. fi
  39. }
  40. # Determine the time since last commit. If branch is clean,
  41. # use a neutral color, otherwise colors will vary according to time.
  42. function _git_time_since_commit() {
  43. # Only proceed if there is actually a commit.
  44. if last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null); then
  45. now=$(date +%s)
  46. seconds_since_last_commit=$((now-last_commit))
  47. # Totals
  48. minutes=$((seconds_since_last_commit / 60))
  49. hours=$((seconds_since_last_commit/3600))
  50. # Sub-hours and sub-minutes
  51. days=$((seconds_since_last_commit / 86400))
  52. sub_hours=$((hours % 24))
  53. sub_minutes=$((minutes % 60))
  54. if [ $hours -gt 24 ]; then
  55. commit_age="${days}d"
  56. elif [ $minutes -gt 60 ]; then
  57. commit_age="${sub_hours}h${sub_minutes}m"
  58. else
  59. commit_age="${minutes}m"
  60. fi
  61. color=$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL
  62. echo "$color$commit_age%{$reset_color%}"
  63. fi
  64. }
  65. if [[ $USER == "root" ]]; then
  66. CARETCOLOR="red"
  67. else
  68. CARETCOLOR="white"
  69. fi
  70. MODE_INDICATOR="%{$fg_bold[yellow]%}❮%{$reset_color%}%{$fg[yellow]%}❮❮%{$reset_color%}"
  71. ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
  72. ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
  73. ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗%{$reset_color%}"
  74. ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔%{$reset_color%}"
  75. ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}✚ "
  76. ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[yellow]%}⚑ "
  77. ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}✖ "
  78. ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}▴ "
  79. ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}§ "
  80. ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[white]%}◒ "
  81. # Colors vary depending on time lapsed.
  82. ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
  83. ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
  84. ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}"
  85. ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[white]%}"
  86. # LS colors, made with https://geoff.greer.fm/lscolors/
  87. export LSCOLORS="exfxcxdxbxegedabagacad"
  88. export LS_COLORS='di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:'
  89. export GREP_COLOR='1;33'