From aeca2ad899eed0235921dc6f1d7a3415bc851143 Mon Sep 17 00:00:00 2001 From: Yad Smood Date: Sun, 21 Feb 2016 01:16:21 +0800 Subject: [PATCH 1/2] Optimize the ys.zsh-theme make it more expressive --- themes/ys.zsh-theme | 50 ++++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/themes/ys.zsh-theme b/themes/ys.zsh-theme index fd8adc41e..d08453350 100644 --- a/themes/ys.zsh-theme +++ b/themes/ys.zsh-theme @@ -1,18 +1,9 @@ # Clean, simple, compatible and meaningful. # Tested on Linux, Unix and Windows under ANSI colors. -# It is recommended to use with a dark background and the font Inconsolata. +# It is recommended to use with a dark background. # Colors: black, red, green, yellow, *blue, magenta, cyan, and white. -# -# http://ysmood.org/wp/2013/03/my-ys-terminal-theme/ -# Mar 2013 ys - -# Machine name. -function box_name { - [ -f ~/.box-name ] && cat ~/.box-name || echo $HOST -} - -# Directory info. -local current_dir='${PWD/#$HOME/~}' +# +# Mar 2013 Yad Smood # VCS YS_VCS_PROMPT_PREFIX1=" %{$fg[white]%}on%{$reset_color%} " @@ -21,7 +12,7 @@ YS_VCS_PROMPT_SUFFIX="%{$reset_color%}" YS_VCS_PROMPT_DIRTY=" %{$fg[red]%}x" YS_VCS_PROMPT_CLEAN=" %{$fg[green]%}o" -# Git info. +# Git info local git_info='$(git_prompt_info)' ZSH_THEME_GIT_PROMPT_PREFIX="${YS_VCS_PROMPT_PREFIX1}git${YS_VCS_PROMPT_PREFIX2}" ZSH_THEME_GIT_PROMPT_SUFFIX="$YS_VCS_PROMPT_SUFFIX" @@ -44,29 +35,24 @@ ys_hg_prompt_info() { fi } -# Prompt format: \n # USER at MACHINE in DIRECTORY on git:BRANCH STATE [TIME] \n $ -PROMPT=" -%{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \ -%{$fg[cyan]%}%n \ -%{$fg[white]%}at \ -%{$fg[green]%}$(box_name) \ -%{$fg[white]%}in \ -%{$terminfo[bold]$fg[yellow]%}${current_dir}%{$reset_color%}\ -${hg_info}\ -${git_info} \ -%{$fg[white]%}[%*] -%{$terminfo[bold]$fg[red]%}$ %{$reset_color%}" -if [[ "$USER" == "root" ]]; then +# Prompt format: +# +# PRIVILEGES USER @ MACHINE in DIRECTORY on git:BRANCH STATE [TIME] L:SHELL_LEVEL N:LINE_NUM +# $ COMMAND +# +# For example: +# +# % ys @ ys-mbp in ~/.oh-my-zsh on git:master x [21:47:42] tty:s000 L:1 N:12 +# $ PROMPT=" %{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \ -%{$bg[yellow]%}%{$fg[cyan]%}%n%{$reset_color%} \ -%{$fg[white]%}at \ -%{$fg[green]%}$(box_name) \ +%(#,%{$bg[yellow]%}%{$fg[black]%}%n%{$reset_color%},%{$fg[cyan]%}%n) \ +%{$fg[white]%}@ \ +%{$fg[green]%}%m \ %{$fg[white]%}in \ -%{$terminfo[bold]$fg[yellow]%}${current_dir}%{$reset_color%}\ +%{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\ ${hg_info}\ ${git_info} \ -%{$fg[white]%}[%*] +%{$fg[white]%}[%*] tty:%l L:%L N:%i %{$terminfo[bold]$fg[red]%}$ %{$reset_color%}" -fi From 9a2376bd29682d9b1c42eb4e0223aacbb784f0fb Mon Sep 17 00:00:00 2001 From: Yad Smood Date: Sun, 21 Feb 2016 02:42:42 +0800 Subject: [PATCH 2/2] add: exit code --- themes/ys.zsh-theme | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/themes/ys.zsh-theme b/themes/ys.zsh-theme index d08453350..737b506be 100644 --- a/themes/ys.zsh-theme +++ b/themes/ys.zsh-theme @@ -35,15 +35,16 @@ ys_hg_prompt_info() { fi } +local exit_code="%(?,%?,%{$fg[red]%}%?%{$reset_color%})" # Prompt format: # -# PRIVILEGES USER @ MACHINE in DIRECTORY on git:BRANCH STATE [TIME] L:SHELL_LEVEL N:LINE_NUM +# PRIVILEGES USER @ MACHINE in DIRECTORY on git:BRANCH STATE [TIME] tty:$TTY L:$SHELL_LEVEL N:LINE_NUM C:LAST_EXIT_CODE # $ COMMAND # # For example: # -# % ys @ ys-mbp in ~/.oh-my-zsh on git:master x [21:47:42] tty:s000 L:1 N:12 +# % ys @ ys-mbp in ~/.oh-my-zsh on git:master x [21:47:42] tty:s000 L:1 N:12 C:0 # $ PROMPT=" %{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \ @@ -53,6 +54,7 @@ PROMPT=" %{$fg[white]%}in \ %{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\ ${hg_info}\ -${git_info} \ -%{$fg[white]%}[%*] tty:%l L:%L N:%i +${git_info}\ + \ +%{$fg[white]%}[%*] tty:%l L:%L N:%i C:$exit_code %{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"