Theme changes

* Load colors before base theme so they can be used by base theme
 * Change git-specific variables to SCM-agnostic ones
pull/23/head
John Schulz 2010-11-09 23:21:19 -05:00
parent 64eb33844d
commit d5645e74a0
9 changed files with 98 additions and 46 deletions

View File

@ -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"

View File

@ -1,27 +1,82 @@
#!/bin/bash
# Stolen from Steve Losh
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 '○'
}
SCM_THEME_PROMPT_DIRTY=' ✗'
SCM_THEME_PROMPT_CLEAN=' ✓'
SCM_THEME_PROMPT_PREFIX=' |'
SCM_THEME_PROMPT_SUFFIX='|'
function parse_git_dirty {
if [[ -n $(git status -s 2> /dev/null) ]]; then
echo -e "$GIT_THEME_PROMPT_DIRTY"
else
echo -e "$GIT_THEME_PROMPT_CLEAN"
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 git_prompt_info() {
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"
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
}
function rvm_version_prompt() {
# Stolen from Steve Losh
# left in for backwards-compatibility
function prompt_char {
char=$(scm_char);
echo -e "$char"
}
function git_prompt_info {
if [[ -n $(git status -s 2> /dev/null) ]]; then
state=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
else
state=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
fi
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 "$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 {
if which rvm &> /dev/null; then
rvm=$(rvm tools identifier) || return
echo -e "$RVM_THEME_PROMPT_PREFIX$rvm$RVM_THEME_PROMPT_SUFFIX"

View File

@ -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="|"

View File

@ -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} "

View File

@ -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]'

View File

@ -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=")"

View File

@ -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=")"

View File

@ -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)}

View File

@ -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:"