From 4c2bb8316150662f7f2152ed59a95bc7ff3a2f38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Franke?= Date: Mon, 24 Oct 2011 15:19:28 +0200 Subject: [PATCH 1/3] Added my personal zsh theme 'ainmosni'. --- themes/ainmosni.zsh-theme | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 themes/ainmosni.zsh-theme diff --git a/themes/ainmosni.zsh-theme b/themes/ainmosni.zsh-theme new file mode 100644 index 000000000..066e56915 --- /dev/null +++ b/themes/ainmosni.zsh-theme @@ -0,0 +1,54 @@ +# Theme with colour changing user and hostname. +# +# Handy if you work on different servers all the time and want a different +# colourscheme when you're root and when you're on certain hosts. +# +# You can put this in your .zshrc to set yourhostname red: +# PRODUCTION_RE='^prod-' +# And for yellow: +# STAGING_RE='^staging-' + +# Default user colour +us_col=$fg[green] +# Make the user colour red if we're root. +if [[ `whoami` == 'root' ]]; then + us_col=$fg[red] +fi + + + + +host_col=$fg[green] +local hostname=`hostname` +if [[ "$PRODUCTION_RE" != "" && "$hostname" =~ "$PRODUCTION_RE" ]]; then + host_col=$fg[red] +elif [[ "$STAGING_RE" != "" && $hostname =~ $STAGING_RE ]]; then + host_col=$fg[yellow] +fi + + + +local start_angular="%{$fg_bold[white]%}[%{$reset_color%}" +local user_at_host="%{$us_col%}%n%{$reset_color%}%{$fg_bold[yellow]%}@%{$reset_color%}%{$host_col%}%m%{$reset_color%}" +local current_path="%{$fg[cyan]%}%2c%{$reset_color%}" +local end_angular="%{$fg_bold[white]%}]%{$reset_color%}" +local user_char="%{$us_col%}%(!.#.$)%{$reset_color%} " +local git_branch='$(git_prompt_status)%{$reset_color%}$(git_prompt_info)%{$reset_color%}' +local current_time="%{$fg_bold[magenta]%}(%D{%Y-%m-%d %H:%M})%{$reset_color%}" + +PROMPT="${start_angular}${user_at_host}:${current_path}${end_angular}${user_char}" +RPROMPT="${git_branch}${current_time}" + +ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[yellow]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="" +ZSH_THEME_GIT_PROMPT_CLEAN="" + + +ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} ✚" +ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg_bold[blue]%} ✹" +ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ✖" +ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} ➜" +ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} ═" +ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭" + From e5b4c4615336c7efcf4fa28161f04fc3e1680b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Franke?= Date: Mon, 24 Oct 2011 15:22:10 +0200 Subject: [PATCH 2/3] Fixed a typo and added my name. --- themes/ainmosni.zsh-theme | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themes/ainmosni.zsh-theme b/themes/ainmosni.zsh-theme index 066e56915..428ecef03 100644 --- a/themes/ainmosni.zsh-theme +++ b/themes/ainmosni.zsh-theme @@ -1,9 +1,10 @@ # Theme with colour changing user and hostname. +# by Daniël Franke # # Handy if you work on different servers all the time and want a different # colourscheme when you're root and when you're on certain hosts. # -# You can put this in your .zshrc to set yourhostname red: +# You can put this in your .zshrc to set your hostname red: # PRODUCTION_RE='^prod-' # And for yellow: # STAGING_RE='^staging-' From f4fb47b2e0162e98d2b161d72f0eaab107b3fda8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Franke?= Date: Mon, 24 Oct 2011 15:27:53 +0200 Subject: [PATCH 3/3] Added some comments to make it more clear. --- themes/ainmosni.zsh-theme | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/themes/ainmosni.zsh-theme b/themes/ainmosni.zsh-theme index 428ecef03..6b38cccf1 100644 --- a/themes/ainmosni.zsh-theme +++ b/themes/ainmosni.zsh-theme @@ -8,6 +8,7 @@ # PRODUCTION_RE='^prod-' # And for yellow: # STAGING_RE='^staging-' +# The contents are regular expression against which the host is matched, # Default user colour us_col=$fg[green] @@ -16,19 +17,18 @@ if [[ `whoami` == 'root' ]]; then us_col=$fg[red] fi - - - +# Default host colour. host_col=$fg[green] local hostname=`hostname` + +# Set the host colour red if it matches the production regex. if [[ "$PRODUCTION_RE" != "" && "$hostname" =~ "$PRODUCTION_RE" ]]; then host_col=$fg[red] +# And yellow if it matches the staging regex. elif [[ "$STAGING_RE" != "" && $hostname =~ $STAGING_RE ]]; then host_col=$fg[yellow] fi - - local start_angular="%{$fg_bold[white]%}[%{$reset_color%}" local user_at_host="%{$us_col%}%n%{$reset_color%}%{$fg_bold[yellow]%}@%{$reset_color%}%{$host_col%}%m%{$reset_color%}" local current_path="%{$fg[cyan]%}%2c%{$reset_color%}"