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