Not for normies
| 1 | # smt.zsh-theme, based on dogenpunk by Matthew Nelson. |
| 2 | |
| 3 | MODE_INDICATOR="%{$fg_bold[red]%}❮%{$reset_color%}%{$fg[red]%}❮❮%{$reset_color%}" |
| 4 | local return_status="%{$fg[red]%}%(?..⏎)%{$reset_color%} " |
| 5 | |
| 6 | ZSH_THEME_GIT_PROMPT_PREFIX="|" |
| 7 | ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" |
| 8 | ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[red]%}⚡%{$reset_color%}" |
| 9 | ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg_bold[red]%}!%{$reset_color%}" |
| 10 | ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}✓%{$reset_color%}" |
| 11 | |
| 12 | ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} ✚" |
| 13 | ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} ✹" |
| 14 | ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ✖" |
| 15 | ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} ➜" |
| 16 | ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} ═" |
| 17 | ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭" |
| 18 | |
| 19 | # Format for git_prompt_long_sha() and git_prompt_short_sha() |
| 20 | ZSH_THEME_GIT_PROMPT_SHA_BEFORE="➤ %{$fg_bold[yellow]%}" |
| 21 | ZSH_THEME_GIT_PROMPT_SHA_AFTER="%{$reset_color%}" |
| 22 | |
| 23 | function prompt_char() { |
| 24 | command git branch &>/dev/null && echo "%{$fg[green]%}±%{$reset_color%}" && return |
| 25 | command hg root &>/dev/null && echo "%{$fg_bold[red]%}☿%{$reset_color%}" && return |
| 26 | command darcs show repo &>/dev/null && echo "%{$fg_bold[green]%}❉%{$reset_color%}" && return |
| 27 | echo "%{$fg[cyan]%}◯%{$reset_color%}" |
| 28 | } |
| 29 | |
| 30 | # Colors vary depending on time lapsed. |
| 31 | ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}" |
| 32 | ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}" |
| 33 | ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}" |
| 34 | ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[cyan]%}" |
| 35 | |
| 36 | # Determine the time since last commit. If branch is clean, |
| 37 | # use a neutral color, otherwise colors will vary according to time. |
| 38 | function git_time_since_commit() { |
| 39 | local COLOR MINUTES HOURS DAYS SUB_HOURS SUB_MINUTES |
| 40 | local last_commit seconds_since_last_commit |
| 41 | |
| 42 | # Only proceed if there is actually a commit |
| 43 | if ! last_commit=$(command git -c log.showSignature=false log --pretty=format:'%at' -1 2>/dev/null); then |
| 44 | echo "[$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL~%{$reset_color%}]" |
| 45 | return |
| 46 | fi |
| 47 | |
| 48 | # Totals |
| 49 | seconds_since_last_commit=$(( EPOCHSECONDS - last_commit )) |
| 50 | MINUTES=$(( seconds_since_last_commit / 60 )) |
| 51 | HOURS=$(( MINUTES / 60 )) |
| 52 | |
| 53 | # Sub-hours and sub-minutes |
| 54 | DAYS=$(( HOURS / 24 )) |
| 55 | SUB_HOURS=$(( HOURS % 24 )) |
| 56 | SUB_MINUTES=$(( MINUTES % 60 )) |
| 57 | |
| 58 | if [[ -z "$(command git status -s 2>/dev/null)" ]]; then |
| 59 | COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL" |
| 60 | else |
| 61 | if [[ "$MINUTES" -gt 30 ]]; then |
| 62 | COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG" |
| 63 | elif [[ "$MINUTES" -gt 10 ]]; then |
| 64 | COLOR="$ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM" |
| 65 | else |
| 66 | COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT" |
| 67 | fi |
| 68 | fi |
| 69 | |
| 70 | if [[ "$HOURS" -gt 24 ]]; then |
| 71 | echo "[${COLOR}${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m%{$reset_color%}]" |
| 72 | elif [[ "$MINUTES" -gt 60 ]]; then |
| 73 | echo "[${COLOR}${HOURS}h${SUB_MINUTES}m%{$reset_color%}]" |
| 74 | else |
| 75 | echo "[${COLOR}${MINUTES}m%{$reset_color%}]" |
| 76 | fi |
| 77 | } |
| 78 | |
| 79 | PROMPT=' |
| 80 | %{$fg[blue]%}%m%{$reset_color%} 福 %{$fg[cyan]%}%~ %{$reset_color%}$(git_prompt_short_sha)$(git_prompt_info) |
| 81 | %{$fg[red]%}%!%{$reset_color%} $(prompt_char) : ' |
| 82 | |
| 83 | RPROMPT='${return_status}$(git_time_since_commit)$(git_prompt_status)%{$reset_color%}' |