From 8f18bd38fd162a03e73bd3ec8c7627b11059481f Mon Sep 17 00:00:00 2001 From: Daniel YC Lin Date: Tue, 6 Aug 2013 17:03:21 +0800 Subject: [PATCH 01/10] show themes featues by grep --- templates/zshrc.zsh-template | 2 +- tools/list_theme.sh | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100755 tools/list_theme.sh diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template index d4dded73a..12092ceff 100644 --- a/templates/zshrc.zsh-template +++ b/templates/zshrc.zsh-template @@ -2,7 +2,7 @@ ZSH=$HOME/.oh-my-zsh # Set name of the theme to load. -# Look in ~/.oh-my-zsh/themes/ +# Look in ~/.oh-my-zsh/themes/ (show features by tools/list_theme.sh) # Optionally, if you set this to "random", it'll load a random theme each # time that oh-my-zsh is loaded. ZSH_THEME="robbyrussell" diff --git a/tools/list_theme.sh b/tools/list_theme.sh new file mode 100755 index 000000000..20faa2d8d --- /dev/null +++ b/tools/list_theme.sh @@ -0,0 +1,34 @@ +#!/bin/zsh +# list_theme is list the feature which theme provides +# usage: list_theme.sh [theme_dir] +# @author Daniel YC Lin +# +# eg. +# list_theme.sh | tee list +# cat list | grep git | grep tty # filter what you want +# . theme/foo.zsh-theme # try the theme +# copy foo.zsh-theme bar.zsh-theme my_theme +# list_theme.sh my_theme # just list themes in a directory + +THEMES_DIR="${1:-$HOME/.oh-my-zsh/themes}" +for f in $THEMES_DIR/*.zsh-theme ; do + echo -n "$(basename $f .zsh-theme) " + grep -q '%?' $f && echo -n "code " + grep -q 'GIT' $f && echo -n "git " + grep -q '%!' $f && echo -n "hist " + grep -q '%h' $f && echo -n "hist " + grep -q '%m' $f && echo -n "host " + grep -q '%H' $f && echo -n "hour " + grep -q '%j' $f && echo -n "job " + grep -q '%L' $f && echo -n "level " + grep -q '%y' $f && echo -n "line " + grep -q '%M' $f && echo -n "machine " + grep -q '%~' $f && echo -n "path " + grep -q '%S' $f && echo -n "sec " + grep -q 'SVN' $f && echo -n "svn " + grep -q '%l' $f && echo -n "tty " + grep -q '%n' $f && echo -n "user " + grep -q '%D' $f && echo -n "date " + echo "" +done +# vim:et sw=2 ts=2 ai From eb271d6eb5cd27356175d86924cc45e2939b499b Mon Sep 17 00:00:00 2001 From: Daniel YC Lin Date: Tue, 6 Aug 2013 17:47:40 +0800 Subject: [PATCH 02/10] support vcs,vcs_info,vcs_info_msg as features --- tools/list_theme.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/list_theme.sh b/tools/list_theme.sh index 20faa2d8d..0b3352f59 100755 --- a/tools/list_theme.sh +++ b/tools/list_theme.sh @@ -14,6 +14,9 @@ THEMES_DIR="${1:-$HOME/.oh-my-zsh/themes}" for f in $THEMES_DIR/*.zsh-theme ; do echo -n "$(basename $f .zsh-theme) " grep -q '%?' $f && echo -n "code " + grep -q 'VCS' $f && echo -n "vcs " + grep -q 'vcs_info' $f && echo -n "vcs_info " + grep -q 'vcs_info_msg' $f && echo -n "vcs_info_msg " grep -q 'GIT' $f && echo -n "git " grep -q '%!' $f && echo -n "hist " grep -q '%h' $f && echo -n "hist " From 089cab61e3b206d2d372ae3e679b9ad2c690a1ff Mon Sep 17 00:00:00 2001 From: Daniel YC Lin Date: Tue, 6 Aug 2013 18:14:47 +0800 Subject: [PATCH 03/10] support %2~ --- tools/list_theme.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/list_theme.sh b/tools/list_theme.sh index 0b3352f59..7f6c22fa1 100755 --- a/tools/list_theme.sh +++ b/tools/list_theme.sh @@ -14,9 +14,7 @@ THEMES_DIR="${1:-$HOME/.oh-my-zsh/themes}" for f in $THEMES_DIR/*.zsh-theme ; do echo -n "$(basename $f .zsh-theme) " grep -q '%?' $f && echo -n "code " - grep -q 'VCS' $f && echo -n "vcs " - grep -q 'vcs_info' $f && echo -n "vcs_info " - grep -q 'vcs_info_msg' $f && echo -n "vcs_info_msg " + grep -q '%D' $f && echo -n "date " grep -q 'GIT' $f && echo -n "git " grep -q '%!' $f && echo -n "hist " grep -q '%h' $f && echo -n "hist " @@ -27,11 +25,16 @@ for f in $THEMES_DIR/*.zsh-theme ; do grep -q '%y' $f && echo -n "line " grep -q '%M' $f && echo -n "machine " grep -q '%~' $f && echo -n "path " + grep -q '%2~' $f && echo -n "path2 " + grep -q 'precmd' $f && echo -n "precmd " + grep -q 'RPROMPT' $f && echo -n "rprompt " grep -q '%S' $f && echo -n "sec " grep -q 'SVN' $f && echo -n "svn " grep -q '%l' $f && echo -n "tty " grep -q '%n' $f && echo -n "user " - grep -q '%D' $f && echo -n "date " + grep -q 'VCS' $f && echo -n "vcs " + grep -q 'vcs_info' $f && echo -n "vcs_info " + grep -q 'vcs_info_msg' $f && echo -n "vcs_info_msg " echo "" done # vim:et sw=2 ts=2 ai From 8da2cbd2e7ab6fb45baa7701c3268acc39f21c31 Mon Sep 17 00:00:00 2001 From: Daniel YC Lin Date: Tue, 6 Aug 2013 18:35:15 +0800 Subject: [PATCH 04/10] added my theme as path3 example --- tools/list_theme.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/list_theme.sh b/tools/list_theme.sh index 7f6c22fa1..dec57dd49 100755 --- a/tools/list_theme.sh +++ b/tools/list_theme.sh @@ -26,6 +26,7 @@ for f in $THEMES_DIR/*.zsh-theme ; do grep -q '%M' $f && echo -n "machine " grep -q '%~' $f && echo -n "path " grep -q '%2~' $f && echo -n "path2 " + grep -q '%3~' $f && echo -n "path3 " grep -q 'precmd' $f && echo -n "precmd " grep -q 'RPROMPT' $f && echo -n "rprompt " grep -q '%S' $f && echo -n "sec " From 38062cb5d68ce764c8272ed3b4887bcef9fc245b Mon Sep 17 00:00:00 2001 From: Daniel YC Lin Date: Tue, 6 Aug 2013 18:40:44 +0800 Subject: [PATCH 05/10] use highlight color as prompt. --- themes/dlintw.zsh-theme | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 themes/dlintw.zsh-theme diff --git a/themes/dlintw.zsh-theme b/themes/dlintw.zsh-theme new file mode 100644 index 000000000..a2297a363 --- /dev/null +++ b/themes/dlintw.zsh-theme @@ -0,0 +1,20 @@ +# Based on cypher and 's prompt http://blog.mired.org/2011/02/adding-vcs-to-zshs-vcsinfo.html +# @author Daniel YC Lin +# Shows the exit status of the last command if non-zero +# Uses "#" instead of "»" when running with elevated privileges +PROMPT="%{$fg_bold[green]%}%D{%H:%M:%S}%(0?. . ${fg[red]}%? )%{${fg[blue]}%}$%{${reset_color}%} " + +autoload -Uz vcs_info +precmd () { vcs_info } + +zstyle ':vcs_info:*' get-revision true +zstyle ':vcs_info:*' check-for-changes true +zstyle ':vcs_info:*' formats '%u%c|%s:%b' +zstyle ':vcs_info:*' actionformats '%c%u|%s@%a:%b' +zstyle ':vcs_info:*' branchformat '%b@%r' +zstyle ':vcs_info:*' unstagedstr "%{$fg_no_bold[red]%}" +zstyle ':vcs_info:*' stagedstr "%{$fg_no_bold[yellow]%}" +zstyle ':vcs_info:*' enable fossil hg svn git cvs # p4 off, but must be last. + +RPROMPT='%n@%m %{$fg_no_bold[magenta]%}%3~%{$fg_no_bold[green]%}${vcs_info_msg_0_}%{$reset_color%}' +setopt PROMPT_SUBST From 82aa8dbdddd0f347ea630f898545573bba0d3f7d Mon Sep 17 00:00:00 2001 From: Daniel YC Lin Date: Wed, 7 Aug 2013 10:21:32 +0800 Subject: [PATCH 06/10] improve dlin theme color and root prompt --- themes/dlintw.zsh-theme | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/themes/dlintw.zsh-theme b/themes/dlintw.zsh-theme index a2297a363..cf85724ab 100644 --- a/themes/dlintw.zsh-theme +++ b/themes/dlintw.zsh-theme @@ -1,8 +1,11 @@ # Based on cypher and 's prompt http://blog.mired.org/2011/02/adding-vcs-to-zshs-vcsinfo.html # @author Daniel YC Lin # Shows the exit status of the last command if non-zero -# Uses "#" instead of "»" when running with elevated privileges -PROMPT="%{$fg_bold[green]%}%D{%H:%M:%S}%(0?. . ${fg[red]}%? )%{${fg[blue]}%}$%{${reset_color}%} " +# Uses "#" instead of "$" when running as root +p_time="%K{black}%B%F{yellow}%D{%H:%M:%S}%k" +p_ret="%(0?.. %F{red}%? )" +p_ps="%B%F{blue}%(#.#.$)%b " +PROMPT="$p_time$ret$p_ps%{$reset_color%}" autoload -Uz vcs_info precmd () { vcs_info } @@ -16,5 +19,5 @@ zstyle ':vcs_info:*' unstagedstr "%{$fg_no_bold[red]%}" zstyle ':vcs_info:*' stagedstr "%{$fg_no_bold[yellow]%}" zstyle ':vcs_info:*' enable fossil hg svn git cvs # p4 off, but must be last. -RPROMPT='%n@%m %{$fg_no_bold[magenta]%}%3~%{$fg_no_bold[green]%}${vcs_info_msg_0_}%{$reset_color%}' +RPROMPT='%F{green}%n@%m %F{magenta}%3~${vcs_info_msg_0_}%{$reset_color%}' setopt PROMPT_SUBST From 88cd7529bc1ff3c95cfb25a589865ff46df23b43 Mon Sep 17 00:00:00 2001 From: Daniel YC Lin Date: Wed, 7 Aug 2013 10:26:05 +0800 Subject: [PATCH 07/10] reset color after prompt --- themes/dlintw.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/dlintw.zsh-theme b/themes/dlintw.zsh-theme index cf85724ab..94b6d7870 100644 --- a/themes/dlintw.zsh-theme +++ b/themes/dlintw.zsh-theme @@ -19,5 +19,5 @@ zstyle ':vcs_info:*' unstagedstr "%{$fg_no_bold[red]%}" zstyle ':vcs_info:*' stagedstr "%{$fg_no_bold[yellow]%}" zstyle ':vcs_info:*' enable fossil hg svn git cvs # p4 off, but must be last. -RPROMPT='%F{green}%n@%m %F{magenta}%3~${vcs_info_msg_0_}%{$reset_color%}' +RPROMPT='%F{green}%n@%m %F{magenta}%3~$%{$reset_color%}${vcs_info_msg_0_}%{$reset_color%}' setopt PROMPT_SUBST From 80240c96221994bf74705ac657a3ba3634a20fb4 Mon Sep 17 00:00:00 2001 From: Daniel YC Lin Date: Thu, 8 Aug 2013 08:44:58 +0000 Subject: [PATCH 08/10] dlintw theme support /etc/debian_chroot settings --- themes/dlintw.zsh-theme | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/themes/dlintw.zsh-theme b/themes/dlintw.zsh-theme index 94b6d7870..873a9dddc 100644 --- a/themes/dlintw.zsh-theme +++ b/themes/dlintw.zsh-theme @@ -2,10 +2,17 @@ # @author Daniel YC Lin # Shows the exit status of the last command if non-zero # Uses "#" instead of "$" when running as root + +# set variable debian_chroot if running in a chroot with /etc/debian_chroot +if [[ -z "$debian_chroot" ]] && [[ -r /etc/debian_chroot ]]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +p_chroot="${debian_chroot:+[$debian_chroot]}" p_time="%K{black}%B%F{yellow}%D{%H:%M:%S}%k" p_ret="%(0?.. %F{red}%? )" p_ps="%B%F{blue}%(#.#.$)%b " -PROMPT="$p_time$ret$p_ps%{$reset_color%}" +PROMPT="$p_chroot$p_time$ret$p_ps%{$reset_color%}" autoload -Uz vcs_info precmd () { vcs_info } From 4a5a63a8ee87421e26f9ef11f74de2de04f8ba81 Mon Sep 17 00:00:00 2001 From: Daniel YC Lin Date: Fri, 16 Aug 2013 11:59:34 +0800 Subject: [PATCH 09/10] Fixed color theme on 'white on black' terminal --- themes/dlintw.zsh-theme | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/themes/dlintw.zsh-theme b/themes/dlintw.zsh-theme index 873a9dddc..b387e7d98 100644 --- a/themes/dlintw.zsh-theme +++ b/themes/dlintw.zsh-theme @@ -3,6 +3,10 @@ # Shows the exit status of the last command if non-zero # Uses "#" instead of "$" when running as root +# ref: http://linux-sxs.org/housekeeping/lscolors.html +# and http://geoff.greer.fm/lscolors/ +export LS_COLORS='di=1;34;47:ln=1;35:so=32;40:pi=33;40:ex=1;31:bd=31;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:' + # set variable debian_chroot if running in a chroot with /etc/debian_chroot if [[ -z "$debian_chroot" ]] && [[ -r /etc/debian_chroot ]]; then debian_chroot=$(cat /etc/debian_chroot) @@ -15,6 +19,7 @@ p_ps="%B%F{blue}%(#.#.$)%b " PROMPT="$p_chroot$p_time$ret$p_ps%{$reset_color%}" autoload -Uz vcs_info +zstyle ':vcs_info:*' enable fossil hg svn git cvs # p4 off, but must be last. precmd () { vcs_info } zstyle ':vcs_info:*' get-revision true @@ -22,9 +27,9 @@ zstyle ':vcs_info:*' check-for-changes true zstyle ':vcs_info:*' formats '%u%c|%s:%b' zstyle ':vcs_info:*' actionformats '%c%u|%s@%a:%b' zstyle ':vcs_info:*' branchformat '%b@%r' +#zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r' zstyle ':vcs_info:*' unstagedstr "%{$fg_no_bold[red]%}" zstyle ':vcs_info:*' stagedstr "%{$fg_no_bold[yellow]%}" -zstyle ':vcs_info:*' enable fossil hg svn git cvs # p4 off, but must be last. RPROMPT='%F{green}%n@%m %F{magenta}%3~$%{$reset_color%}${vcs_info_msg_0_}%{$reset_color%}' setopt PROMPT_SUBST From e4a96f8e4812d72a66b666d2b8dda2d6c617285b Mon Sep 17 00:00:00 2001 From: Daniel YC Lin Date: Sun, 18 Aug 2013 18:52:13 +0800 Subject: [PATCH 10/10] fixed bug of PS1 p_ret code --- themes/dlintw.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/dlintw.zsh-theme b/themes/dlintw.zsh-theme index b387e7d98..8f02627c5 100644 --- a/themes/dlintw.zsh-theme +++ b/themes/dlintw.zsh-theme @@ -16,7 +16,7 @@ p_chroot="${debian_chroot:+[$debian_chroot]}" p_time="%K{black}%B%F{yellow}%D{%H:%M:%S}%k" p_ret="%(0?.. %F{red}%? )" p_ps="%B%F{blue}%(#.#.$)%b " -PROMPT="$p_chroot$p_time$ret$p_ps%{$reset_color%}" +PROMPT="$p_chroot$p_time$p_ret$p_ps%{$reset_color%}" autoload -Uz vcs_info zstyle ':vcs_info:*' enable fossil hg svn git cvs # p4 off, but must be last.