avit.zsh-theme 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # AVIT ZSH Theme
  2. # settings
  3. typeset +H _current_dir="%{$fg_bold[blue]%}%3~%{$reset_color%} "
  4. typeset +H _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}"
  5. typeset +H _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
  6. PROMPT='
  7. $(_user_host)${_current_dir} $(git_prompt_info) $(ruby_prompt_info)
  8. %{%(!.${fg[red]}.${fg[white]})%}▶%{$reset_color%} '
  9. PROMPT2='%{%(!.${fg[red]}.${fg[white]})%}◀%{$reset_color%} '
  10. __RPROMPT='$(vi_mode_prompt_info)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
  11. if [[ -z $RPROMPT ]]; then
  12. RPROMPT=$__RPROMPT
  13. else
  14. RPROMPT="${RPROMPT} ${__RPROMPT}"
  15. fi
  16. function _user_host() {
  17. local me
  18. if [[ -n $SSH_CONNECTION ]]; then
  19. me="%n@%m"
  20. elif [[ $LOGNAME != $USERNAME ]]; then
  21. me="%n"
  22. fi
  23. if [[ -n $me ]]; then
  24. echo "%{$fg[cyan]%}$me%{$reset_color%}:"
  25. fi
  26. }
  27. # Determine the time since last commit. If branch is clean,
  28. # use a neutral color, otherwise colors will vary according to time.
  29. function _git_time_since_commit() {
  30. local last_commit now seconds_since_last_commit
  31. local minutes hours days years commit_age
  32. # Only proceed if there is actually a commit.
  33. if last_commit=$(command git -c log.showSignature=false log --format='%at' -1 2>/dev/null); then
  34. now=$(date +%s)
  35. seconds_since_last_commit=$((now-last_commit))
  36. # Totals
  37. minutes=$((seconds_since_last_commit / 60))
  38. hours=$((minutes / 60))
  39. days=$((hours / 24))
  40. years=$((days / 365))
  41. if [[ $years -gt 0 ]]; then
  42. commit_age="${years}y$((days % 365 ))d"
  43. elif [[ $days -gt 0 ]]; then
  44. commit_age="${days}d$((hours % 24))h"
  45. elif [[ $hours -gt 0 ]]; then
  46. commit_age+="${hours}h$(( minutes % 60 ))m"
  47. else
  48. commit_age="${minutes}m"
  49. fi
  50. echo "${ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL}${commit_age}%{$reset_color%}"
  51. fi
  52. }
  53. MODE_INDICATOR="%{$fg_bold[yellow]%}❮%{$reset_color%}%{$fg[yellow]%}❮❮%{$reset_color%}"
  54. # Git prompt settings
  55. ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
  56. ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
  57. ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗%{$reset_color%}"
  58. ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔%{$reset_color%}"
  59. ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}✚ "
  60. ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[yellow]%}⚑ "
  61. ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}✖ "
  62. ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}▴ "
  63. ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}§ "
  64. ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[white]%}◒ "
  65. # Ruby prompt settings
  66. ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[grey]%}"
  67. ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}"
  68. # Colors vary depending on time lapsed.
  69. ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
  70. ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
  71. ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}"
  72. ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[white]%}"
  73. # LS colors, made with https://geoff.greer.fm/lscolors/
  74. export LSCOLORS="exfxcxdxbxegedabagacad"
  75. 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:'
  76. export GREP_COLORS='mt=1;33'