avit.zsh-theme 3.0 KB

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