keylanzsh

My edit of the Dieter Zsh theme
git clone git://git.ckyln.com/keylanzsh.git
Log | Files | Refs

commit d2c3f271d1b90c5811a15be2614f72f999a9d1a1
Author: Cem Keylan <cem@ckyln.com>
Date:   Wed, 26 Jun 2019 14:31:23 +0300

Initial Commit

Diffstat:
Akeylan.zsh-theme | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+), 0 deletions(-)

diff --git a/keylan.zsh-theme b/keylan.zsh-theme @@ -0,0 +1,58 @@ +# Cem Keylan's edit of the dieter theme + +# the idea of this theme is to contain a lot of info in a small string, by +# compressing some parts and colorcoding, which bring useful visual cues, +# while limiting the amount of colors and such to keep it easy on the eyes. +# When a command exited >0, the timestamp will be in red and the exit code +# will be on the right edge. +# The exit code visual cues will only display once. +# (i.e. they will be reset, even if you hit enter a few times on empty command prompts) + +typeset -A host_repr + +# translate hostnames into shortened, colorcoded strings +host_repr=('dieter-ws-a7n8x-arch' "%{$fg_bold[green]%}ws" 'dieter-p4sci-arch' "%{$fg_bold[blue]%}p4") + +# local time, color coded by last return code +time_enabled="%(?.%{$fg[green]%}.%{$fg[red]%})%*%{$reset_color%}" +time_disabled="%{$fg[green]%}%*%{$reset_color%}" +time=$time_disabled + +# user part, color coded by privileges +local user="%(!.%{$fg_bold[yellow]%}.%{$fg_bold[yellow]%})%n%{$reset_color%}" + +# Hostname part. compressed and colorcoded per host_repr array +# if not found, regular hostname in default color +local host="%(?.%{$fg_bold[green]%}.%{$fg_bold[green]%})@%(?.%{$fg_bold[cyan]%}.%{$fg_bold[cyan]%})${host_repr[$HOST]:-$HOST}%{$reset_color%}" + +# Compacted $PWD +local pwd="%{$fg_bold[red]%}%c%{$reset_color%}" + +PROMPT='${user}${host} ${pwd} $(git_prompt_info)%(?.%{$fg_bold[cyan]%}.%{$fg_bold[cyan]%})->%{$reset_color%} ' + +# i would prefer 1 icon that shows the "most drastic" deviation from HEAD, +# but lets see how this works out +ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[yellow]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[green]%} %{$fg_bold[yellow]%}?%{$fg_bold[green]%}%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}" + +# elaborate exitcode on the right when >0 +return_code_enabled="%(?..%{$fg_bold[red]%}%? ↵%{$reset_color%})" +return_code_disabled= +return_code=$return_code_enabled + +RPS1='${return_code}' + +function accept-line-or-clear-warning () { + if [[ -z $BUFFER ]]; then + time=$time_disabled + return_code=$return_code_disabled + else + time=$time_enabled + return_code=$return_code_enabled + fi + zle accept-line +} +zle -N accept-line-or-clear-warning +bindkey '^M' accept-line-or-clear-warning