Not for normies
| 1 | # the idea of this theme is to contain a lot of info in a small string, by |
| 2 | # compressing some parts and colorcoding, which bring useful visual cues, |
| 3 | # while limiting the amount of colors and such to keep it easy on the eyes. |
| 4 | # When a command exited >0, the timestamp will be in red and the exit code |
| 5 | # will be on the right edge. |
| 6 | # The exit code visual cues will only display once. |
| 7 | # (i.e. they will be reset, even if you hit enter a few times on empty command prompts) |
| 8 | |
| 9 | typeset -g -A host_repr |
| 10 | |
| 11 | # translate hostnames into shortened, colorcoded strings |
| 12 | host_repr=('dieter-ws-a7n8x-arch' "%{$fg_bold[green]%}ws" 'dieter-p4sci-arch' "%{$fg_bold[blue]%}p4") |
| 13 | |
| 14 | # local time, color coded by last return code |
| 15 | time_enabled="%(?.%{$fg[green]%}.%{$fg[red]%})%*%{$reset_color%}" |
| 16 | time_disabled="%{$fg[green]%}%*%{$reset_color%}" |
| 17 | time=$time_enabled |
| 18 | |
| 19 | # user part, color coded by privileges |
| 20 | local user="%(!.%{$fg[blue]%}.%{$fg[blue]%})%n%{$reset_color%}" |
| 21 | |
| 22 | # Hostname part. compressed and colorcoded per host_repr array |
| 23 | # if not found, regular hostname in default color |
| 24 | local host="@${host_repr[$HOST]:-$HOST}%{$reset_color%}" |
| 25 | |
| 26 | # Compacted $PWD |
| 27 | local pwd="%{$fg[blue]%}%c%{$reset_color%}" |
| 28 | |
| 29 | PROMPT='${time} ${user}${host} ${pwd} $(git_prompt_info)' |
| 30 | |
| 31 | # i would prefer 1 icon that shows the "most drastic" deviation from HEAD, |
| 32 | # but lets see how this works out |
| 33 | ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}" |
| 34 | ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " |
| 35 | ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%} %{$fg[yellow]%}?%{$fg[green]%}%{$reset_color%}" |
| 36 | ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}" |
| 37 | |
| 38 | # elaborate exitcode on the right when >0 |
| 39 | return_code_enabled="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" |
| 40 | return_code_disabled= |
| 41 | return_code=$return_code_enabled |
| 42 | |
| 43 | RPS1='${return_code}' |
| 44 | |
| 45 | function accept-line-or-clear-warning () { |
| 46 | if [[ -z $BUFFER ]]; then |
| 47 | time=$time_disabled |
| 48 | return_code=$return_code_disabled |
| 49 | else |
| 50 | time=$time_enabled |
| 51 | return_code=$return_code_enabled |
| 52 | fi |
| 53 | zle accept-line |
| 54 | } |
| 55 | zle -N accept-line-or-clear-warning |
| 56 | bindkey '^M' accept-line-or-clear-warning |