avit.zsh-theme 2.9 KB

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