From 3c72480fcb27b6427a255c10038d68741c40cbd1 Mon Sep 17 00:00:00 2001 From: Michele Bologna Date: Wed, 17 Sep 2014 15:26:31 +0200 Subject: [PATCH 1/2] michelebologna theme now declares variables as "local" to avoid variable clashing with other scripts --- plugins/rails/rails.plugin.zsh | 2 +- themes/michelebologna.zsh-theme | 59 +++++++++++++++++---------------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index fb46cdcf0..d43efbc70 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -58,7 +58,7 @@ alias rn='rake notes' alias rr='rake routes' # legacy stuff -alias ss='thin --stats "/thin/stats" start' +alias sstat='thin --stats "/thin/stats" start' alias sg='ruby script/generate' alias sd='ruby script/destroy' alias sp='ruby script/plugin' diff --git a/themes/michelebologna.zsh-theme b/themes/michelebologna.zsh-theme index ef4c6d740..7a4d4ab58 100644 --- a/themes/michelebologna.zsh-theme +++ b/themes/michelebologna.zsh-theme @@ -1,44 +1,47 @@ +# Michele Bologna theme +# mbologna on GitHub +# # reference colors -GREEN="%{$fg_bold[green]%}" -RED="%{$fg_bold[red]%}" -CYAN="%{$fg_bold[cyan]%}" -YELLOW="%{$fg_bold[yellow]%}" -BLUE="%{$fg_bold[blue]%}" -MAGENTA="%{$fg_bold[magenta]%}" -WHITE="%{$fg_bold[white]%}" +local GREEN="%{$fg_bold[green]%}" +local RED="%{$fg_bold[red]%}" +local CYAN="%{$fg_bold[cyan]%}" +local YELLOW="%{$fg_bold[yellow]%}" +local BLUE="%{$fg_bold[blue]%}" +local MAGENTA="%{$fg_bold[magenta]%}" +local WHITE="%{$fg_bold[white]%}" +local COLOR_ARRAY COLOR_ARRAY=($GREEN $RED $CYAN $YELLOW $BLUE $MAGENTA $WHITE) # color reset -RESET_COLOR="%{$reset_color%}" +local RESET_COLOR="%{$reset_color%}" # which color should be applied? -USERNAME_NORMAL_COLOR=$WHITE -USERNAME_ROOT_COLOR=$RED -HOSTNAME_NORMAL_COLOR=$BLUE -# uncomment next line if you want auto-generated hostname color -#for i in `hostname`; HOSTNAME_NORMAL_COLOR=$COLOR_ARRAY[$[((#i))%7+1]] -HOSTNAME_ROOT_COLOR=$RED +local USERNAME_NORMAL_COLOR=$WHITE +local USERNAME_ROOT_COLOR=$RED +for i in `hostname`; local HOSTNAME_NORMAL_COLOR=$COLOR_ARRAY[$[((#i))%7+1]] +local HOSTNAME_ROOT_COLOR=$RED +local HOSTNAME_COLOR HOSTNAME_COLOR=%(!.$HOSTNAME_ROOT_COLOR.$HOSTNAME_NORMAL_COLOR) -CURRENT_DIR_COLOR=$CYAN +local CURRENT_DIR_COLOR=$CYAN # zsh commands -USERNAME_COMMAND="%n" -HOSTNAME_COMMAND="%m" -CURRENT_DIR="%~" +local USERNAME_COMMAND="%n" +local HOSTNAME_COMMAND="%m" +local CURRENT_DIR="%~" # output: colors + commands -USERNAME_OUTPUT="%(!..$USERNAME_NORMAL_COLOR$USERNAME_COMMAND$RESET_COLOR@)" -HOSTNAME_OUTPUT="$HOSTNAME_COLOR$HOSTNAME_COMMAND$RESET_COLOR" -CURRENT_DIR_OUTPUT="$CURRENT_DIR_COLOR$CURRENT_DIR" -LAST_COMMAND_OUTPUT="%(?.%(!.$RED.$GREEN).$YELLOW)" +local USERNAME_OUTPUT="%(!..$USERNAME_NORMAL_COLOR$USERNAME_COMMAND$RESET_COLOR@)" +local HOSTNAME_OUTPUT="$HOSTNAME_COLOR$HOSTNAME_COMMAND$RESET_COLOR" +local CURRENT_DIR_OUTPUT="$CURRENT_DIR_COLOR$CURRENT_DIR" +local LAST_COMMAND_OUTPUT="%(?.%(!.$RED.$GREEN).$YELLOW)" # git theming -ZSH_THEME_GIT_PROMPT_PREFIX="(" -ZSH_THEME_GIT_PROMPT_SUFFIX="" -ZSH_THEME_GIT_PROMPT_DIRTY=")$RED*" -ZSH_THEME_GIT_PROMPT_CLEAN=")" +local ZSH_THEME_GIT_PROMPT_PREFIX="(" +local ZSH_THEME_GIT_PROMPT_SUFFIX="" +local ZSH_THEME_GIT_PROMPT_DIRTY=")$RED*" +local ZSH_THEME_GIT_PROMPT_CLEAN=")" # wrap all together -PROMPT='$USERNAME_OUTPUT$HOSTNAME_OUTPUT:$CURRENT_DIR_OUTPUT $LAST_COMMAND_OUTPUT%#$RESET_COLOR ' -RPROMPT='%1(j.fg: [%j].) $GREEN$(git_prompt_info)$RESET_COLOR [%@]' +export PROMPT='$USERNAME_OUTPUT$HOSTNAME_OUTPUT:$CURRENT_DIR_OUTPUT $LAST_COMMAND_OUTPUT%#$RESET_COLOR ' +export RPROMPT='%1(j.fg: [%j].) $GREEN$(git_prompt_info)$RESET_COLOR [%@]' From 5a1142315af1d21a96cda7acaabe22f47e3c1d59 Mon Sep 17 00:00:00 2001 From: Michele Bologna Date: Wed, 17 Sep 2014 20:23:26 +0200 Subject: [PATCH 2/2] declared lowercase variables, as in https://google-styleguide.googlecode.com/svn/trunk/shell.xml --- themes/michelebologna.zsh-theme | 80 +++++++++++++++++---------------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/themes/michelebologna.zsh-theme b/themes/michelebologna.zsh-theme index 7a4d4ab58..06991c66b 100644 --- a/themes/michelebologna.zsh-theme +++ b/themes/michelebologna.zsh-theme @@ -1,47 +1,49 @@ -# Michele Bologna theme -# mbologna on GitHub +# Michele Bologna's theme +# http://michelebologna.net +# +# This a theme for oh-my-zsh. Features a colored prompt with a right prompt +# containing the git status (if applicable). +# The '%' prompt will be green if last command return value is 0, yellow otherwise. +# The hostname color is based on hostname characters (see below). +# When using as root, the left prompt shows only the hostname in red color. # -# reference colors -local GREEN="%{$fg_bold[green]%}" -local RED="%{$fg_bold[red]%}" -local CYAN="%{$fg_bold[cyan]%}" -local YELLOW="%{$fg_bold[yellow]%}" -local BLUE="%{$fg_bold[blue]%}" -local MAGENTA="%{$fg_bold[magenta]%}" -local WHITE="%{$fg_bold[white]%}" -local COLOR_ARRAY -COLOR_ARRAY=($GREEN $RED $CYAN $YELLOW $BLUE $MAGENTA $WHITE) +local green="%{$fg_bold[green]%}" +local red="%{$fg_bold[red]%}" +local cyan="%{$fg_bold[cyan]%}" +local yellow="%{$fg_bold[yellow]%}" +local blue="%{$fg_bold[blue]%}" +local magenta="%{$fg_bold[magenta]%}" +local white="%{$fg_bold[white]%}" +local reset="%{$reset_color%}" -# color reset -local RESET_COLOR="%{$reset_color%}" +local color_array +color_array=($green $red $cyan $yellow $blue $magenta $white) -# which color should be applied? -local USERNAME_NORMAL_COLOR=$WHITE -local USERNAME_ROOT_COLOR=$RED -for i in `hostname`; local HOSTNAME_NORMAL_COLOR=$COLOR_ARRAY[$[((#i))%7+1]] -local HOSTNAME_ROOT_COLOR=$RED -local HOSTNAME_COLOR -HOSTNAME_COLOR=%(!.$HOSTNAME_ROOT_COLOR.$HOSTNAME_NORMAL_COLOR) -local CURRENT_DIR_COLOR=$CYAN +local username_normal_color=$white +local username_root_color=$red +local hostname_root_color=$red -# zsh commands -local USERNAME_COMMAND="%n" -local HOSTNAME_COMMAND="%m" -local CURRENT_DIR="%~" +# calculating the hostname color with hostname characters +for i in `hostname`; local hostname_normal_color=$color_array[$[((#i))%7+1]] -# output: colors + commands -local USERNAME_OUTPUT="%(!..$USERNAME_NORMAL_COLOR$USERNAME_COMMAND$RESET_COLOR@)" -local HOSTNAME_OUTPUT="$HOSTNAME_COLOR$HOSTNAME_COMMAND$RESET_COLOR" -local CURRENT_DIR_OUTPUT="$CURRENT_DIR_COLOR$CURRENT_DIR" -local LAST_COMMAND_OUTPUT="%(?.%(!.$RED.$GREEN).$YELLOW)" +local hostname_color +hostname_color=%(!.$hostname_root_color.$hostname_normal_color) +local current_dir_color=$cyan -# git theming -local ZSH_THEME_GIT_PROMPT_PREFIX="(" -local ZSH_THEME_GIT_PROMPT_SUFFIX="" -local ZSH_THEME_GIT_PROMPT_DIRTY=")$RED*" -local ZSH_THEME_GIT_PROMPT_CLEAN=")" +local username_command="%n" +local hostname_command="%m" +local current_dir="%~" -# wrap all together -export PROMPT='$USERNAME_OUTPUT$HOSTNAME_OUTPUT:$CURRENT_DIR_OUTPUT $LAST_COMMAND_OUTPUT%#$RESET_COLOR ' -export RPROMPT='%1(j.fg: [%j].) $GREEN$(git_prompt_info)$RESET_COLOR [%@]' +local username_output="%(!..$username_normal_color$username_command$reset@)" +local hostname_output="$hostname_color$hostname_command$reset" +local current_dir_output="$current_dir_color$current_dir" +local last_command_output="%(?.%(!.$red.$green).$yellow)" + +export ZSH_THEME_GIT_PROMPT_PREFIX="(" +export ZSH_THEME_GIT_PROMPT_SUFFIX="" +export ZSH_THEME_GIT_PROMPT_DIRTY=")$red*" +export ZSH_THEME_GIT_PROMPT_CLEAN=")" + +export PROMPT='$username_output$hostname_output:$current_dir_output $last_command_output%#$reset ' +export RPROMPT='%1(j.fg: [%j].) $green$(git_prompt_info)$reset [%@]'