From 2dec362881a4ba7fa83b61cb652f3d10110ebbc8 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Wed, 24 Nov 2010 18:03:14 +0100 Subject: [PATCH 1/3] add dieter theme v1 --- themes/dieter.zsh-theme | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 themes/dieter.zsh-theme diff --git a/themes/dieter.zsh-theme b/themes/dieter.zsh-theme new file mode 100644 index 00000000..5b61c80c --- /dev/null +++ b/themes/dieter.zsh-theme @@ -0,0 +1,33 @@ +# 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 +# exact return code (when >0) is on the right, so it stays out of the way + +# TODO: reset exit code visual cues (not exit code itself) after showing once +# TODO: compress hostname in window title + +typeset -A host_repr +host_repr=('dieter-ws-a7n8x-arch' "%{$fg_bold[green]%}ws" 'dieter-p4sci-arch' "%{$fg_bold[blue]%}p4") + + +# local time, color coded after last return code +local time="%(?.%{$fg[green]%}.%{$fg[red]%})%*%{$reset_color%}" +# user part, color coded after privileges +local user="%(!.%{$fg[blue]%}.%{$fg[blue]%})%n%{$reset_color%}" +# Hostname part. compressed and colorcoded per host_repr array +# if not found, regular hostname in default color +local host="@${host_repr[$(hostname)]:-$(hostname)}%{$reset_color%}" +# Compacted $PWD +local pwd="%{$fg[blue]%}%c%{$reset_color%}" + +PROMPT='${time} ${user}${host} ${pwd} $(git_prompt_info)' + +# 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[yellow]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%} %{$fg[yellow]%}?%{$fg[green]%}%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}" + +# elaborate exitcode on the right when >0 +local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" +RPS1="${return_code}" From 5a40696650a4233dabcc786f989e7b78903c1466 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Wed, 24 Nov 2010 19:58:03 +0100 Subject: [PATCH 2/3] reset exit code visual cues (not exit code itself) after showing once --- themes/dieter.zsh-theme | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/themes/dieter.zsh-theme b/themes/dieter.zsh-theme index 5b61c80c..a14829fc 100644 --- a/themes/dieter.zsh-theme +++ b/themes/dieter.zsh-theme @@ -2,21 +2,25 @@ # and colorcoding, which bring useful visual cues. While limiting the amount of colors and such to keep # it easy on the eyes # exact return code (when >0) is on the right, so it stays out of the way - -# TODO: reset exit code visual cues (not exit code itself) after showing once -# TODO: compress hostname in window title +# The visual cues for >0 exit codes 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 host_repr=('dieter-ws-a7n8x-arch' "%{$fg_bold[green]%}ws" 'dieter-p4sci-arch' "%{$fg_bold[blue]%}p4") # local time, color coded after last return code -local time="%(?.%{$fg[green]%}.%{$fg[red]%})%*%{$reset_color%}" +time_enabled="%(?.%{$fg[green]%}.%{$fg[red]%})%*%{$reset_color%}" +time_disabled="%{$fg[green]%}%*%{$reset_color%}" +time=$time_enabled + # user part, color coded after privileges local user="%(!.%{$fg[blue]%}.%{$fg[blue]%})%n%{$reset_color%}" + # Hostname part. compressed and colorcoded per host_repr array # if not found, regular hostname in default color local host="@${host_repr[$(hostname)]:-$(hostname)}%{$reset_color%}" + # Compacted $PWD local pwd="%{$fg[blue]%}%c%{$reset_color%}" @@ -29,5 +33,21 @@ ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%} %{$fg[yellow]%}?%{$fg[green]%}%{$rese ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}" # elaborate exitcode on the right when >0 -local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" -RPS1="${return_code}" +return_code_enabled="%(?..%{$fg[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 From af4784e627dd64bafef5f72d2a6eca41c1702cd4 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Wed, 24 Nov 2010 20:04:40 +0100 Subject: [PATCH 3/3] better phrasing/documentation --- themes/dieter.zsh-theme | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/themes/dieter.zsh-theme b/themes/dieter.zsh-theme index a14829fc..0a5e9265 100644 --- a/themes/dieter.zsh-theme +++ b/themes/dieter.zsh-theme @@ -1,20 +1,22 @@ -# 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 -# exact return code (when >0) is on the right, so it stays out of the way -# The visual cues for >0 exit codes will only display once +# 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 -host_repr=('dieter-ws-a7n8x-arch' "%{$fg_bold[green]%}ws" 'dieter-p4sci-arch' "%{$fg_bold[blue]%}p4") +# 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 after last return code +# local time, color coded by last return code time_enabled="%(?.%{$fg[green]%}.%{$fg[red]%})%*%{$reset_color%}" time_disabled="%{$fg[green]%}%*%{$reset_color%}" time=$time_enabled -# user part, color coded after privileges +# user part, color coded by privileges local user="%(!.%{$fg[blue]%}.%{$fg[blue]%})%n%{$reset_color%}" # Hostname part. compressed and colorcoded per host_repr array @@ -26,7 +28,8 @@ local pwd="%{$fg[blue]%}%c%{$reset_color%}" PROMPT='${time} ${user}${host} ${pwd} $(git_prompt_info)' -# i would prefer 1 icon that shows the "most drastic" deviation from head, but lets see how this works out +# 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[yellow]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%} %{$fg[yellow]%}?%{$fg[green]%}%{$reset_color%}"