avit.zsh-theme 3.2 KB

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