c3224900b7f9f619a99cb6f3a32ba985eaaf1be4

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge branch 'dieter-theme' of https://github.com/Dieterbe/oh-my-zsh into Dieterbe-dieter-theme

Diff

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