dieter.zsh-theme
2047 bytes
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
9typeset -g -A host_repr
10
11# translate hostnames into shortened, colorcoded strings
12host_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
15time_enabled="%(?.%{$fg[green]%}.%{$fg[red]%})%*%{$reset_color%}"
16time_disabled="%{$fg[green]%}%*%{$reset_color%}"
17time=$time_enabled
18
19# user part, color coded by privileges
20local 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
24local host="@${host_repr[$HOST]:-$HOST}%{$reset_color%}"
25
26# Compacted $PWD
27local pwd="%{$fg[blue]%}%c%{$reset_color%}"
28
29PROMPT='${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
33ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}"
34ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
35ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%} %{$fg[yellow]%}?%{$fg[green]%}%{$reset_color%}"
36ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}"
37
38# elaborate exitcode on the right when >0
39return_code_enabled="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
40return_code_disabled=
41return_code=$return_code_enabled
42
43RPS1='${return_code}'
44
45function 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}
55zle -N accept-line-or-clear-warning
56bindkey '^M' accept-line-or-clear-warning