From: John Schulz Date: Wed, 10 Nov 2010 04:21:19 +0000 (-0500) Subject: Theme changes X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=d5645e74a0eacf0c7cf743c09a5dad1ff990db8a;p=common%2Fbash_it.git Theme changes * Load colors before base theme so they can be used by base theme * Change git-specific variables to SCM-agnostic ones --- diff --git a/bash_it.sh b/bash_it.sh index 5736f89..0d42fcc 100644 --- a/bash_it.sh +++ b/bash_it.sh @@ -6,12 +6,9 @@ alias reload='source ~/.bash_profile' # Load the framework -# Themes -THEMES="${BASH}/themes/*.bash" -for config_file in $THEMES -do - source $config_file -done +# Load colors first so they can be use in base theme +source "${BASH}/themes/colors.theme.bash" +source "${BASH}/themes/base.theme.bash" # Library LIB="${BASH}/lib/*.bash" diff --git a/themes/base.theme.bash b/themes/base.theme.bash index f898875..9ae5d0e 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -1,27 +1,82 @@ #!/bin/bash +SCM_THEME_PROMPT_DIRTY=' ✗' +SCM_THEME_PROMPT_CLEAN=' ✓' +SCM_THEME_PROMPT_PREFIX=' |' +SCM_THEME_PROMPT_SUFFIX='|' + +GIT='git' +SCM_GIT_CHAR='±' + +HG='hg' +SCM_HG_CHAR='☿' + +SVN='svn' +SCM_SVN_CHAR='⑆' + +SCM_NONE_CHAR='○' + +RVM_THEME_PROMPT_PREFIX=' |' +RVM_THEME_PROMPT_SUFFIX='|' + +function scm { + if [[ -d .git ]]; then SCM=$GIT + elif [[ -d .hg ]]; then SCM=$HG + elif [[ -d .svn ]]; then SCM=$SVN + else SCM='NONE' + fi +} + +function scm_char { + if [[ -z $SCM ]]; then scm; fi + [[ $SCM == $GIT ]] && echo $SCM_GIT_CHAR && return + [[ $SCM == $HG ]] && echo $SCM_HG_CHAR && return + [[ $SCM == $SVN ]] && echo $SCM_SVN_CHAR && return + echo $SCM_NONE_CHAR +} + +function scm_prompt_info { + if [[ -z $SCM ]]; then scm; fi + [[ $SCM == $GIT ]] && git_prompt_info && return + [[ $SCM == $HG ]] && hg_prompt_info && return + [[ $SCM == $SVN ]] && svn_prompt_info && return +} + # Stolen from Steve Losh +# left in for backwards-compatibility function prompt_char { - git branch >/dev/null 2>/dev/null && echo -e '±' && return - hg root >/dev/null 2>/dev/null && echo -e '☿' && return - echo -e '○' + char=$(scm_char); + echo -e "$char" } -function parse_git_dirty { +function git_prompt_info { if [[ -n $(git status -s 2> /dev/null) ]]; then - echo -e "$GIT_THEME_PROMPT_DIRTY" + state=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} else - echo -e "$GIT_THEME_PROMPT_CLEAN" + state=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} fi -} - -function git_prompt_info() { + prefix=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} + suffix=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} ref=$(git symbolic-ref HEAD 2> /dev/null) || return - echo -e "$GIT_THEME_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$GIT_THEME_PROMPT_SUFFIX" + + echo -e "$prefix${ref#refs/heads/}$state$suffix" } +function svn_prompt_info { + if [[ -n $(svn status 2> /dev/null) ]]; then + state=${SVN_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} + else + state=${SVN_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} + fi + prefix=${SVN_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} + suffix=${SVN_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} + ref=$(svn info 2> /dev/null | awk -F/ '/^URL:/ { for (i=0; i<=NF; i++) { if ($i == "branches" || $i == "tags" ) { print $(i+1); break }; if ($i == "trunk") { print $i; break } } }') || return + + [[ -z $ref ]] && return + echo -e "$prefix$ref$state$suffix" +} -function rvm_version_prompt() { +function rvm_version_prompt { if which rvm &> /dev/null; then rvm=$(rvm tools identifier) || return echo -e "$RVM_THEME_PROMPT_PREFIX$rvm$RVM_THEME_PROMPT_SUFFIX" diff --git a/themes/bobby/bobby.theme.bash b/themes/bobby/bobby.theme.bash index 8eb50c5..f0f8447 100644 --- a/themes/bobby/bobby.theme.bash +++ b/themes/bobby/bobby.theme.bash @@ -1,6 +1,10 @@ #!/bin/bash +SCM_THEME_PROMPT_DIRTY=" ${red}✗" +SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" +SCM_THEME_PROMPT_PREFIX=" |" +SCM_THEME_PROMPT_SUFFIX="${green}|" -PROMPT="\[${bold_blue}\]\[\$(prompt_char)\]\[\$(git_prompt_info)\]\[${blue}\]\[\$(rvm_version_prompt) \]\[${orange}\]\h \[${reset_color}\]in \[${green}\]\w \[${reset_color}\]\[→ " +PROMPT="${bold_blue}\[\$(scm_char)\]${green}\$(scm_prompt_info)${blue}\$(rvm_version_prompt) ${orange}\h ${reset_color}in ${green}\w ${reset_color}\]\[→ " # git theming GIT_THEME_PROMPT_DIRTY=" ${red}✗" @@ -10,3 +14,4 @@ GIT_THEME_PROMPT_SUFFIX="${green}|" RVM_THEME_PROMPT_PREFIX=" |" RVM_THEME_PROMPT_SUFFIX="|" + diff --git a/themes/candy/candy.theme.bash b/themes/candy/candy.theme.bash index 7158a9e..ef0ba26 100644 --- a/themes/candy/candy.theme.bash +++ b/themes/candy/candy.theme.bash @@ -1,2 +1,2 @@ #!/bin/bash -PROMPT="${green}\u@\h ${blue}\T ${reset_color}${white}\w${reset_color}\[\$(git_prompt_info)\]${blue} →${bold_blue} \$${reset_color} " \ No newline at end of file +PROMPT="${green}\u@\h ${blue}\T ${reset_color}${white}\w${reset_color}\[\$(scm_prompt_info)\]${blue} →${bold_blue} \$${reset_color} " \ No newline at end of file diff --git a/themes/clean/clean.theme.bash b/themes/clean/clean.theme.bash index 88949fd..2fc418f 100644 --- a/themes/clean/clean.theme.bash +++ b/themes/clean/clean.theme.bash @@ -1,6 +1,6 @@ if [ "$(whoami)" = root ]; then no_color=$red; else no_color=$white; fi -PROMPT="${no_color}\u${reset_color}:${blue}\W/${reset_color} \[\$(git_prompt_info)\]$ " +PROMPT="${no_color}\u${reset_color}:${blue}\W/${reset_color} \[\$(scm_prompt_info)\]$ " RPROMPT='[\t]' diff --git a/themes/pete/pete.theme.bash b/themes/pete/pete.theme.bash index 1f9b4fc..95f243a 100644 --- a/themes/pete/pete.theme.bash +++ b/themes/pete/pete.theme.bash @@ -5,16 +5,16 @@ prompt_setter() { history -a history -c history -r - PS1="(\t) $(prompt_char) [\[$blue\]\u\[$reset_color\]@\[$green\]\H\[$reset_color\]] \[$yellow\]\w\[$reset_color\]$(git_prompt_info)$(rvm_version_prompt) $\[$reset_color\] " + PS1="(\t) $(scm_char) [\[$blue\]\u\[$reset_color\]@\[$green\]\H\[$reset_color\]] \[$yellow\]\w\[$reset_color\]$(scm_prompt_info)$(rvm_version_prompt) $\[$reset_color\] " PS2='> ' PS4='+ ' } PROMPT_COMMAND=prompt_setter -GIT_THEME_PROMPT_DIRTY=" ✗" -GIT_THEME_PROMPT_CLEAN=" ✓" -GIT_THEME_PROMPT_PREFIX=" (" -GIT_THEME_PROMPT_SUFFIX=")" +SCM_THEME_PROMPT_DIRTY=" ✗" +SCM_THEME_PROMPT_CLEAN=" ✓" +SCM_THEME_PROMPT_PREFIX=" (" +SCM_THEME_PROMPT_SUFFIX=")" RVM_THEME_PROMPT_PREFIX=" (" RVM_THEME_PROMPT_SUFFIX=")" diff --git a/themes/simple/simple.theme.bash b/themes/simple/simple.theme.bash index 5a8d5d9..2dcd7e7 100644 --- a/themes/simple/simple.theme.bash +++ b/themes/simple/simple.theme.bash @@ -11,16 +11,11 @@ case $TERM in TITLEBAR="" ;; esac -PROMPT="${TITLEBAR}${orange}${reset_color}${green}\w${bold_blue}\[\$(git_prompt_info)\]${reset_color} " +PROMPT="${TITLEBAR}${orange}${reset_color}${green}\w${bold_blue}\[\$(scm_prompt_info)\]${reset_color} " -# git themeing -# GIT_THEME_PROMPT_DIRTY=" ${red}✗" -# GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓" -# GIT_THEME_PROMPT_PREFIX=" ${green}|" -# GIT_THEME_PROMPT_SUFFIX="${green}|" - -GIT_THEME_PROMPT_DIRTY=" ✗" -GIT_THEME_PROMPT_CLEAN=" ✓" -GIT_THEME_PROMPT_PREFIX="(" -GIT_THEME_PROMPT_SUFFIX=")" +# scm themeing +SCM_THEME_PROMPT_DIRTY=" ✗" +SCM_THEME_PROMPT_CLEAN=" ✓" +SCM_THEME_PROMPT_PREFIX="(" +SCM_THEME_PROMPT_SUFFIX=")" diff --git a/themes/standard/standard.theme.bash b/themes/standard/standard.theme.bash index 61a9cbc..5ba288c 100644 --- a/themes/standard/standard.theme.bash +++ b/themes/standard/standard.theme.bash @@ -2,11 +2,11 @@ PROMPT='\[${green}\]\u\[${normal}\]@\[${green}\]\h\[${normal}\]:\[${blue}\]\w\[$ -# git themeing -GIT_THEME_PROMPT_DIRTY="×" -GIT_THEME_PROMPT_CLEAN="✓" -GIT_THEME_PROMPT_PREFIX="" -GIT_THEME_PROMPT_SUFFIX="" +# scm themeing +SCM_THEME_PROMPT_DIRTY="×" +SCM_THEME_PROMPT_CLEAN="✓" +SCM_THEME_PROMPT_PREFIX="" +SCM_THEME_PROMPT_SUFFIX="" # TODO: need a check for OS before adding this to the prompt # ${debian_chroot:+($debian_chroot)} diff --git a/themes/zitron/zitron.theme.bash b/themes/zitron/zitron.theme.bash index 980b19a..c072686 100644 --- a/themes/zitron/zitron.theme.bash +++ b/themes/zitron/zitron.theme.bash @@ -17,4 +17,4 @@ GIT_THEME_PROMPT_SUFFIX="" ## ls colors # thanks a lot to http://geoff.greer.fm/lscolors/ export LSCOLORS="Gxfxcxdxbxegedabagacad" -export LS_COLORS="no=00:fi=00:di=01;97:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;34:*.svg=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:" +export LS_COLORS="no=00:fi=00:di=01;33:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;34:*.svg=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:"