avit.zsh-theme 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. if git rev-parse --git-dir > /dev/null 2>&1; then
  34. # Only proceed if there is actually a commit.
  35. if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then
  36. # Get the last commit.
  37. last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null)
  38. now=$(date +%s)
  39. seconds_since_last_commit=$((now-last_commit))
  40. # Totals
  41. minutes=$((seconds_since_last_commit / 60))
  42. hours=$((seconds_since_last_commit/3600))
  43. # Sub-hours and sub-minutes
  44. days=$((seconds_since_last_commit / 86400))
  45. sub_hours=$((hours % 24))
  46. sub_minutes=$((minutes % 60))
  47. if [ $hours -gt 24 ]; then
  48. commit_age="${days}d"
  49. elif [ $minutes -gt 60 ]; then
  50. commit_age="${sub_hours}h${sub_minutes}m"
  51. else
  52. commit_age="${minutes}m"
  53. fi
  54. color=$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL
  55. echo "$color$commit_age%{$reset_color%}"
  56. fi
  57. fi
  58. }
  59. if [[ $USER == "root" ]]; then
  60. CARETCOLOR="red"
  61. else
  62. CARETCOLOR="white"
  63. fi
  64. MODE_INDICATOR="%{$fg_bold[yellow]%}❮%{$reset_color%}%{$fg[yellow]%}❮❮%{$reset_color%}"
  65. ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
  66. ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
  67. ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗%{$reset_color%}"
  68. ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔%{$reset_color%}"
  69. ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}✚ "
  70. ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[yellow]%}⚑ "
  71. ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}✖ "
  72. ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}▴ "
  73. ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}§ "
  74. ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[grey]%}◒ "
  75. # Colors vary depending on time lapsed.
  76. ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
  77. ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
  78. ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}"
  79. ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[grey]%}"
  80. # LS colors, made with http://geoff.greer.fm/lscolors/
  81. export LSCOLORS="exfxcxdxbxegedabagacad"
  82. 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:'
  83. export GREP_COLOR='1;33'