Skip to content

Commit

Permalink
Theme changes
Browse files Browse the repository at this point in the history
 * Load colors before base theme so they can be used by base theme
 * Change git-specific variables to SCM-agnostic ones
  • Loading branch information
jfsiii committed Nov 10, 2010
1 parent 64eb338 commit d5645e7
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 42 deletions.
9 changes: 3 additions & 6 deletions bash_it.sh
Expand Up @@ -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"
Expand Down
77 changes: 66 additions & 11 deletions 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"
Expand Down
7 changes: 6 additions & 1 deletion 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}"
Expand All @@ -10,3 +14,4 @@ GIT_THEME_PROMPT_SUFFIX="${green}|"

RVM_THEME_PROMPT_PREFIX=" |"
RVM_THEME_PROMPT_SUFFIX="|"

2 changes: 1 addition & 1 deletion 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} "
PROMPT="${green}\u@\h ${blue}\T ${reset_color}${white}\w${reset_color}\[\$(scm_prompt_info)\]${blue}${bold_blue} \$${reset_color} "
2 changes: 1 addition & 1 deletion 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]'


Expand Down
10 changes: 5 additions & 5 deletions themes/pete/pete.theme.bash
Expand Up @@ -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=")"
17 changes: 6 additions & 11 deletions themes/simple/simple.theme.bash
Expand Up @@ -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=")"
10 changes: 5 additions & 5 deletions themes/standard/standard.theme.bash
Expand Up @@ -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)}
Expand Down
2 changes: 1 addition & 1 deletion themes/zitron/zitron.theme.bash
Expand Up @@ -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:"

0 comments on commit d5645e7

Please sign in to comment.