diff --git a/.gitignore b/.gitignore index 6be7eefe..33e5fca9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +aliases/enabled plugins/enabled .DS_Store custom/*.bash diff --git a/aliases/emacs.aliases.bash b/aliases/available/emacs.aliases.bash similarity index 100% rename from aliases/emacs.aliases.bash rename to aliases/available/emacs.aliases.bash diff --git a/aliases/general.aliases.bash b/aliases/available/general.aliases.bash similarity index 58% rename from aliases/general.aliases.bash rename to aliases/available/general.aliases.bash index d91fbbb6..79bd7aa0 100644 --- a/aliases/general.aliases.bash +++ b/aliases/available/general.aliases.bash @@ -17,9 +17,10 @@ fi alias c='clear' alias k='clear' +alias cls='clear' alias edit="$EDITOR" -alias page="$PAGER" +alias pager="$PAGER" alias q="exit" @@ -48,22 +49,25 @@ alias rd=rmdir function aliases-help() { echo "Generic Alias Usage" echo - echo " sl = ls" - echo " ls = ls -G" - echo " la = ls -AF" - echo " ll = ls -al" - echo " l = ls -a" - echo " c/k = clear" - echo " .. = cd .." - echo " ... = cd ../.." - echo " - = cd -" - echo " h = history" - echo " md = mkdir -p" - echo " rd = rmdir" - echo " editor = $EDITOR" - echo " pager = $PAGER" - echo " piano = pianobar" - echo " q = exit" - echo " irc = $IRC_CLIENT" - echo + echo " sl = ls" + echo " ls = ls -G" + echo " la = ls -AF" + echo " ll = ls -al" + echo " l = ls -a" + echo " c/k/cls = clear" + echo " .. = cd .." + echo " ... = cd ../.." + echo " - = cd -" + echo " h = history" + echo " md = mkdir -p" + echo " rd = rmdir" + echo " editor = $EDITOR" + echo " pager = $PAGER" + echo " piano = pianobar" + echo " q = exit" + echo " irc = $IRC_CLIENT" + echo " md = mkdir -p" + echo " rd = rmdir" + echo " rb = ruby" + echo } diff --git a/aliases/git.aliases.bash b/aliases/available/git.aliases.bash similarity index 100% rename from aliases/git.aliases.bash rename to aliases/available/git.aliases.bash diff --git a/aliases/heroku.aliases.bash b/aliases/available/heroku.aliases.bash similarity index 100% rename from aliases/heroku.aliases.bash rename to aliases/available/heroku.aliases.bash diff --git a/aliases/hg.aliases.bash b/aliases/available/hg.aliases.bash similarity index 100% rename from aliases/hg.aliases.bash rename to aliases/available/hg.aliases.bash diff --git a/aliases/available/homebrew.aliases.bash b/aliases/available/homebrew.aliases.bash new file mode 100644 index 00000000..051081d9 --- /dev/null +++ b/aliases/available/homebrew.aliases.bash @@ -0,0 +1,24 @@ +# Some aliases for Homebrew + +alias bup="brew update && brew upgrade" +alias bout="brew outdated" +alias bin="brew install" +alias brm="brew uninstall" +alias bls="brew list" +alias bsr="brew search" +alias binf="brew info" +alias bdr="brew doctor" + +function brew-help() { + echo "Homebrew Alias Usage" + echo + echo "bup = brew update && brew upgrade" + echo "bout = brew outdated" + echo "bin = brew install" + echo "brm = brew uninstall" + echo "bls = brew list" + echo "bsr = brew search" + echo "binf = brew info" + echo "bdr = brew doctor" + echo +} diff --git a/aliases/jekyll.aliases.bash b/aliases/available/jekyll.aliases.bash similarity index 100% rename from aliases/jekyll.aliases.bash rename to aliases/available/jekyll.aliases.bash diff --git a/aliases/osx.aliases.bash b/aliases/available/osx.aliases.bash similarity index 100% rename from aliases/osx.aliases.bash rename to aliases/available/osx.aliases.bash diff --git a/aliases/rails.aliases.bash b/aliases/available/rails.aliases.bash similarity index 100% rename from aliases/rails.aliases.bash rename to aliases/available/rails.aliases.bash diff --git a/aliases/textmate.aliases.bash b/aliases/available/textmate.aliases.bash similarity index 100% rename from aliases/textmate.aliases.bash rename to aliases/available/textmate.aliases.bash diff --git a/aliases/todo.txt-cli.aliases.bash b/aliases/available/todo.txt-cli.aliases.bash similarity index 100% rename from aliases/todo.txt-cli.aliases.bash rename to aliases/available/todo.txt-cli.aliases.bash diff --git a/aliases/vim.aliases.bash b/aliases/available/vim.aliases.bash similarity index 100% rename from aliases/vim.aliases.bash rename to aliases/available/vim.aliases.bash diff --git a/bash_it.sh b/bash_it.sh index 4a9b30d3..b52ff97f 100644 --- a/bash_it.sh +++ b/bash_it.sh @@ -37,12 +37,22 @@ do done # Aliases -FUNCTIONS="${BASH}/aliases/*.bash" +if [ ! -d "${BASH}/aliases/enabled" ] +then + mkdir "${BASH}/aliases/enabled" + ln -s ${BASH}/aliases/available/* "${BASH}/aliases/enabled" +fi +FUNCTIONS="${BASH}/aliases/enabled/*.bash" for config_file in $FUNCTIONS do source $config_file done +if [ -e "${BASH}/aliases/custom.aliases.bash" ] +then + source "${BASH}/aliases/custom.aliases.bash" +fi + # Custom CUSTOM="${BASH}/custom/*.bash" for config_file in $CUSTOM @@ -73,6 +83,7 @@ function bash-it() { echo " rails-help This will list out all the aliases you can use with rails." echo " git-help This will list out all the aliases you can use with git." echo " todo-help This will list out all the aliases you can use with todo.txt-cli" + echo " brew-help This will list out all the aliases you can use with Homebrew" echo " aliases-help Generic list of aliases." echo " plugins-help This will list out all the plugins and functions you can use with bash-it" echo diff --git a/plugins/available/battery.plugin.bash b/plugins/available/battery.plugin.bash index 4946c2c9..7c158122 100644 --- a/plugins/available/battery.plugin.bash +++ b/plugins/available/battery.plugin.bash @@ -69,11 +69,11 @@ battery_charge(){ local F_C='▸' # Depleted char local D_C='▹' - local DEPLETED_COLOR='\[${normal}\]' - local FULL_COLOR='\[${green}\]' - local HALF_COLOR='\[${yellow}\]' - local DANGER_COLOR='\[${red}\]' - local BATTERY_OUTPUT='${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${D_C}' + local DEPLETED_COLOR="${normal}" + local FULL_COLOR="${green}" + local HALF_COLOR="${yellow}" + local DANGER_COLOR="${red}" + local BATTERY_OUTPUT="${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${D_C}" local BATTERY_PERC=$(battery_percentage) case $BATTERY_PERC in @@ -123,7 +123,7 @@ battery_charge(){ echo "${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${normal}" ;; *) - echo "${DANGER_COLOR}UNPLG\[${normal}\]" + echo "${DANGER_COLOR}UNPLG${normal}" ;; esac } diff --git a/plugins/available/javascript.plugins.bash b/plugins/available/javascript.plugins.bash index 2e0b56cb..a480d9e4 100644 --- a/plugins/available/javascript.plugins.bash +++ b/plugins/available/javascript.plugins.bash @@ -3,15 +3,30 @@ # The install directory is hard-coded. TOOD: allow the directory to be specified on the command line. # +[[ -z "$JQUERY_VERSION_NUMBER" ]] && JQUERY_VERSION_NUMBER="1.6.1" +[[ -z "$JQUERY_UI_VERSION_NUMBER" ]] && JQUERY_UI_VERSION_NUMBER="1.8.13" function rails_jquery { curl -o public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js } function jquery_install { - curl -o public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js + if [ -z "$1" ] + then + version=$JQUERY_VERSION_NUMBER + else + version="$1" + fi + curl -o public/javascripts/jquery.js "http://ajax.googleapis.com/ajax/libs/jquery/$version/jquery.min.js" } -function jquery_ui_install { - curl -o public/javascripts/jquery_ui.js http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js -} \ No newline at end of file +function jquery_ui_install { + if [ -z "$1" ] + then + version=$JQUERY_UI_VERSION_NUMBER + else + version="$1" + fi + + curl -o public/javascripts/jquery_ui.js "http://ajax.googleapis.com/ajax/libs/jqueryui/$version/jquery-ui.min.js" +} diff --git a/plugins/available/rvm.plugin.bash b/plugins/available/rvm.plugin.bash index d3c81ed4..e158a800 100644 --- a/plugins/available/rvm.plugin.bash +++ b/plugins/available/rvm.plugin.bash @@ -1,16 +1,29 @@ #!/bin/bash -switch () { - rvm $1 - local v=$(rvm_version) - rvm wrapper $1 textmate - echo "Switch to Ruby version: "$v -} -rvm_default () { - rvm --default $1 - rvm wrapper $1 textmate -} +# Load RVM, if you are using it +[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm -function rvm_version () { - ruby --version -} \ No newline at end of file +# Check to make sure that RVM is actually loaded before adding +# the customizations to it. +if [ "$rvm_path" ] +then + # Load the auto-completion script if RVM was loaded. + [[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion + + switch () { + rvm $1 + local v=$(rvm_version) + rvm wrapper $1 textmate + echo "Switch to Ruby version: "$v + } + + rvm_default () { + rvm --default $1 + rvm wrapper $1 textmate + } + + function rvm_version () { + ruby --version + } + +fi diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 70876622..feee64e8 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -20,10 +20,14 @@ SCM_NONE_CHAR='○' RVM_THEME_PROMPT_PREFIX=' |' RVM_THEME_PROMPT_SUFFIX='|' +VIRTUALENV_THEME_PROMPT_PREFIX=' |' +VIRTUALENV_THEME_PROMPT_SUFFIX='|' + function scm { if [[ -d .git ]]; then SCM=$GIT elif [[ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]]; then SCM=$GIT elif [[ -d .hg ]]; then SCM=$HG + elif [[ -n "$(hg root 2> /dev/null)" ]]; then SCM=$HG elif [[ -d .svn ]]; then SCM=$SVN else SCM='NONE' fi @@ -78,9 +82,30 @@ function svn_prompt_info { echo -e "$prefix$ref$state$suffix" } +function hg_prompt_info() { + if [[ -n $(hg status 2> /dev/null) ]]; then + state=${HG_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} + else + state=${HG_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} + fi + prefix=${HG_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} + suffix=${HG_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} + branch=$(hg summary 2> /dev/null | grep branch | awk '{print $2}') + changeset=$(hg summary 2> /dev/null | grep parent | awk '{print $2}') + + echo -e "$prefix$branch:${changeset#*:}$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" fi } + +function virtualenv_prompt { + if which virtualenv &> /dev/null; then + virtualenv=$([ ! -z "$VIRTUAL_ENV" ] && echo "`basename $VIRTUAL_ENV`") || return + echo -e "$VIRTUALENV_THEME_PROMPT_PREFIX$virtualenv$VIRTUALENV_THEME_PROMPT_SUFFIX" + fi +} diff --git a/themes/bobby/bobby.theme.bash b/themes/bobby/bobby.theme.bash index 8b48ddd9..cb51fb85 100644 --- a/themes/bobby/bobby.theme.bash +++ b/themes/bobby/bobby.theme.bash @@ -4,15 +4,6 @@ SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" SCM_THEME_PROMPT_PREFIX=" |" SCM_THEME_PROMPT_SUFFIX="${green}|" - -# PROMPT="\[${bold_cyan}\]\[\$(scm_char)\]\[${green}\]\[\$(scm_prompt_info)\]\[${purple}\]\[\$(rvm_version_prompt)\] \[${yellow}\]\h \[${reset_color}\]in \[${green}\]\w \[${reset_color}\]\[\n\[${green}\]→\[${reset_color}\] " - - -PROMPT="\n\[${yellow}\]\[\$(rvm_version_prompt)\] \[${purple}\]\h \[${reset_color}\]in \[${green}\]\w\n\[${bold_cyan}\]\[\$(scm_char)\]\[${green}\]\[\$(scm_prompt_info)\] \[\[${green}\]→\[${reset_color}\] " - - - -# git theming GIT_THEME_PROMPT_DIRTY=" ${red}✗" GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓" GIT_THEME_PROMPT_PREFIX=" ${green}|" @@ -21,3 +12,9 @@ GIT_THEME_PROMPT_SUFFIX="${green}|" RVM_THEME_PROMPT_PREFIX="|" RVM_THEME_PROMPT_SUFFIX="|" +function prompt_command() { + #PS1="${bold_cyan}$(scm_char)${green}$(scm_prompt_info)${purple}$(rvm_version_prompt) ${yellow}\h ${reset_color}in ${green}\w ${reset_color}\n${green}→${reset_color} " + PS1="\n${yellow}$(rvm_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}→${reset_color} " +} + +PROMPT_COMMAND=prompt_command; diff --git a/themes/candy/candy.theme.bash b/themes/candy/candy.theme.bash index ef0ba262..64d31b83 100644 --- a/themes/candy/candy.theme.bash +++ b/themes/candy/candy.theme.bash @@ -1,2 +1,6 @@ #!/bin/bash -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 +function prompt_command() { + PS1="${green}\u@\h ${blue}\T ${reset_color}${white}\w${reset_color}$(scm_prompt_info)\]${blue} →${bold_blue} ${reset_color} "; +} + +PROMPT_COMMAND=prompt_command; diff --git a/themes/clean/clean.theme.bash b/themes/clean/clean.theme.bash index 2fc418f8..9998d65e 100644 --- a/themes/clean/clean.theme.bash +++ b/themes/clean/clean.theme.bash @@ -1,9 +1,3 @@ -if [ "$(whoami)" = root ]; then no_color=$red; else no_color=$white; fi - -PROMPT="${no_color}\u${reset_color}:${blue}\W/${reset_color} \[\$(scm_prompt_info)\]$ " -RPROMPT='[\t]' - - # git theming ZSH_THEME_GIT_PROMPT_PREFIX="${bold_blue}(${yellow}%B" ZSH_THEME_GIT_PROMPT_SUFFIX="%b${bold_blue})${reset_color} " @@ -13,4 +7,14 @@ ZSH_THEME_GIT_PROMPT_DIRTY="${bold_red}✗" # LS colors, made with http://geoff.greer.fm/lscolors/ export LSCOLORS="Gxfxcxdxbxegedabagacad" -export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:' \ No newline at end of file +export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:' + +function prompt_command() { + + if [ "$(whoami)" = root ]; then no_color=$red; else no_color=$white; fi + + PS1="${no_color}\u${reset_color}:${blue}\W/${reset_color} \[\$(scm_prompt_info)\]$ " + RPROMPT='[\t]' +} + +PROMPT_COMMAND=prompt_command; diff --git a/themes/colors.theme.bash b/themes/colors.theme.bash index 9aa253f5..ff8776d2 100644 --- a/themes/colors.theme.bash +++ b/themes/colors.theme.bash @@ -1,44 +1,44 @@ #!/bin/bash -black=$'\e[0;30m' -red=$'\e[0;31m' -green=$'\e[0;32m' -yellow=$'\e[0;33m' -blue=$'\e[0;34m' -purple=$'\e[0;35m' -cyan=$'\e[0;36m' -white=$'\e[1;37m' -orange=$'\e[33;40m' +black="\[\e[0;30m\]" +red="\[\e[0;31m\]" +green="\[\e[0;32m\]" +yellow="\[\e[0;33m\]" +blue="\[\e[0;34m\]" +purple="\[\e[0;35m\]" +cyan="\[\e[0;36m\]" +white="\[\e[1;37m\]" +orange="\[\e[33;40m\]" -bold_black=$'\e[1;30m' -bold_red=$'\e[1;31m' -bold_green=$'\e[1;32m' -bold_yellow=$'\e[1;33m' -bold_blue=$'\e[1;34m' -bold_purple=$'\e[1;35m' -bold_cyan=$'\e[1;36m' -bold_white=$'\e[1;37m' -bold_orange=$'\e[1;33;40m' +bold_black="\[\e[1;30m\]" +bold_red="\[\e[1;31m\]" +bold_green="\[\e[1;32m\]" +bold_yellow="\[\e[1;33m\]" +bold_blue="\[\e[1;34m\]" +bold_purple="\[\e[1;35m\]" +bold_cyan="\[\e[1;36m\]" +bold_white="\[\e[1;37m\]" +bold_orange="\[\e[1;33;40m\]" -underline_black=$'\e[4;30m' -underline_red=$'\e[4;31m' -underline_green=$'\e[4;32m' -underline_yellow=$'\e[4;33m' -underline_blue=$'\e[4;34m' -underline_purple=$'\e[4;35m' -underline_cyan=$'\e[4;36m' -underline_white=$'\e[4;37m' -underline_orange=$'\e[4;33;40m' +underline_black="\[\e[4;30m\]" +underline_red="\[\e[4;31m\]" +underline_green="\[\e[4;32m\]" +underline_yellow="\[\e[4;33m\]" +underline_blue="\[\e[4;34m\]" +underline_purple="\[\e[4;35m\]" +underline_cyan="\[\e[4;36m\]" +underline_white="\[\e[4;37m\]" +underline_orange="\[\e[4;33;40m\]" -background_black=$'\e[40m' -background_red=$'\e[41m' -background_green=$'\e[42m' -background_yellow=$'\e[43m' -background_blue=$'\e[44m' -background_purple=$'\e[45m' -background_cyan=$'\e[46m' -background_white=$'\e[47m' +background_black="\[\e[40m\]" +background_red="\[\e[41m\]" +background_green="\[\e[42m\]" +background_yellow="\[\e[43m\]" +background_blue="\[\e[44m\]" +background_purple="\[\e[45m\]" +background_cyan="\[\e[46m\]" +background_white="\[\e[47m\]" -normal=$'\e[00m' -reset_color=$'\e[39m' \ No newline at end of file +normal="\[\e[00m\]" +reset_color="\[\e[39m\]" diff --git a/themes/demula/demula.theme.bash b/themes/demula/demula.theme.bash index 0e6744a4..bd48e12c 100644 --- a/themes/demula/demula.theme.bash +++ b/themes/demula/demula.theme.bash @@ -33,22 +33,22 @@ #*color7: #E5E5E5 # ----------------------------------------------------------------- COLOR CONF -D_DEFAULT_COLOR='\[${normal}\]' -D_INTERMEDIATE_COLOR='\[${white}\]' -D_USER_COLOR='\[${purple}\]' -D_SUPERUSER_COLOR='\[${red}\]' -D_MACHINE_COLOR='\[${cyan}\]' -D_DIR_COLOR='\[${green}\]' -D_SCM_COLOR='\[${yellow}\]' -D_BRANCH_COLOR='\[${yellow}\]' -D_CHANGES_COLOR='\[${white}\]' -D_CMDFAIL_COLOR='\[${red}\]' -D_VIMSHELL_COLOR='\[${cyan}\]' +D_DEFAULT_COLOR="${normal}" +D_INTERMEDIATE_COLOR="${white}" +D_USER_COLOR="${purple}" +D_SUPERUSER_COLOR="${red}" +D_MACHINE_COLOR="${cyan}" +D_DIR_COLOR="${green}" +D_SCM_COLOR="${yellow}" +D_BRANCH_COLOR="${yellow}" +D_CHANGES_COLOR="${white}" +D_CMDFAIL_COLOR="${red}" +D_VIMSHELL_COLOR="${cyan}" # ------------------------------------------------------------------ FUNCTIONS case $TERM in xterm*) - TITLEBAR="\[\033]0;\w\007\]" + TITLEBAR="\033]0;\w\007" ;; *) TITLEBAR="" @@ -84,10 +84,10 @@ ${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}" # -------------------------------------------------------------- PROMPT OUTPUT prompt() { - local SAVE_CURSOR='\[\033[s\]' - local RESTORE_CURSOR='\[\033[u\]' - local MOVE_CURSOR_RIGHTMOST='\[\033[500C\]' - local MOVE_CURSOR_5_LEFT='\[\033[5D\]' + local SAVE_CURSOR='\033[s' + local RESTORE_CURSOR='\033[u' + local MOVE_CURSOR_RIGHTMOST='\033[500C' + local MOVE_CURSOR_5_LEFT='\033[5D' if [ $(uname) = "Linux" ]; then diff --git a/themes/doubletime/doubletime.theme.bash b/themes/doubletime/doubletime.theme.bash index c5a8a420..1237f80f 100644 --- a/themes/doubletime/doubletime.theme.bash +++ b/themes/doubletime/doubletime.theme.bash @@ -1,9 +1,9 @@ #!/bin/bash SCM_THEME_PROMPT_DIRTY='' SCM_THEME_PROMPT_CLEAN='' -SCM_GIT_CHAR='${bold_cyan}±${normal}' -SCM_SVN_CHAR='${bold_cyan}⑆${normal}' -SCM_HG_CHAR='${bold_red}☿${normal}' +SCM_GIT_CHAR="${bold_cyan}±${normal}" +SCM_SVN_CHAR="${bold_cyan}⑆${normal}" +SCM_HG_CHAR="${bold_red}☿${normal}" SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" RVM_THEME_PROMPT_PREFIX=" (" @@ -32,14 +32,20 @@ virtualenv_prompt() { fi } -prompt_setter() { +function prompt_setter() { # Save history history -a history -c history -r + if [[ -z "$THEME_PROMPT_CLOCK_FORMAT" ]] + then + clock="\t" + else + clock=$THEME_PROMPT_CLOCK_FORMAT + fi PS1=" -\t $(scm_char) [\[$THEME_PROMPT_HOST_COLOR\]\u@${THEME_PROMPT_HOST}\[$reset_color\]] $(virtualenv_prompt)\w -$(doubletime_scm_prompt)\[$reset_color\] $ " +$clock $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)\w +$(doubletime_scm_prompt)$reset_color $ " PS2='> ' PS4='+ ' } diff --git a/themes/hawaii50/hawaii50.theme.bash b/themes/hawaii50/hawaii50.theme.bash new file mode 100644 index 00000000..21c0b413 --- /dev/null +++ b/themes/hawaii50/hawaii50.theme.bash @@ -0,0 +1,187 @@ +#!/bin/bash +# +# This theme was obviously inspired a lot by +# +# - Demula theme +# +# which in itself was inspired by : +# +# - Ronacher's dotfiles (mitsuhikos) - http://github.com/mitsuhiko/dotfiles/tree/master/bash/ +# - Glenbot - http://theglenbot.com/custom-bash-shell-for-development/ +# - My extravagant zsh - http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/ +# - Monokai colors - http://monokai.nl/blog/2006/07/15/textmate-color-theme/ +# - Bash_it modern theme +# +# Hawaii50 theme supports : +# +# - configurable directory length +# - hg, svn, git detection (I work in all of them) +# - virtualenv, rvm + gemsets +# +# Screenshot: http://i.imgur.com/4IAMJ.png +# +# by Ryan Kanno +# +# And yes, we code out in Hawaii. :D +# +# Note: I also am really new to this bash scripting game, so if you see things +# that are flat out wrong, or if you think of something neat, just send a pull +# request. This probably only works on a Mac - as some functions are OS +# specific like getting ip, etc. +# + +# COLORS ====================================================================== +ORANGE='\[\e[0;33m\]' + +DEFAULT_COLOR="${white}" + +USER_COLOR="${purple}" +SUPERUSER_COLOR="${red}" +MACHINE_COLOR=$ORANGE +IP_COLOR=$ORANGE +DIRECTORY_COLOR="${green}" + +VE_COLOR="${cyan}" +RVM_COLOR="${cyan}" + +REF_COLOR="${purple}" + +# SCM prompts +SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}" +SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}" +SCM_THEME_PROMPT_PREFIX=' on ' +SCM_THEME_PROMPT_SUFFIX='' + +# rvm prompts +RVM_THEME_PROMPT_PREFIX='' +RVM_THEME_PROMPT_SUFFIX='' + +# virtualenv prompts +VIRTUALENV_THEME_PROMPT_PREFIX='' +VIRTUALENV_THEME_PROMPT_SUFFIX='' + +# virtual prompts +VIRTUAL_PROMPT_ENABLED=1 + +VIRTUAL_THEME_PROMPT_PREFIX=' using ' +VIRTUAL_THEME_PROMPT_SUFFIX='' + +# Max length of PWD to display +MAX_PWD_LENGTH=20 + +# Max length of Git Hex to display +MAX_GIT_HEX_LENGTH=5 + +# IP address +IP_SEPARATOR=', ' + +# FUNCS ======================================================================= + +function ip { + myip=$(curl -s checkip.dyndns.org | grep -Eo '[0-9\.]+') + echo -e "$(ips | sed -e :a -e '$!N;s/\n/${IP_SEPARATOR}/;ta' | sed -e 's/127\.0\.0\.1\${IP_SEPARATOR}//g'), ${myip}" +} + +# Displays virtual info prompt (virtualenv/rvm) +function virtual_prompt_info() { + local virtual_env_info=$(virtualenv_prompt) + local rvm_info=$(rvm_version_prompt) + local virtual_prompt="" + + local prefix=${VIRTUAL_THEME_PROMPT_PREFIX} + local suffix=${VIRTUAL_THEME_PROMPT_SUFFIX} + + # If no virtual info, just return + [[ -z "$virtual_env_info" && -z "$rvm_info" ]] && return + + # If virtual_env info present, append to prompt + [[ -n "$virtual_env_info" ]] && virtual_prompt="virtualenv: ${VE_COLOR}$virtual_env_info${DEFAULT_COLOR}" + + if [[ -n "$rvm_info" ]] + then + [[ -n "$virtual_env_info" ]] && virtual_prompt="$virtual_prompt, " + virtual_prompt="${virtual_prompt}rvm: ${RVM_COLOR}$rvm_info${DEFAULT_COLOR}" + fi + echo -e "$prefix$virtual_prompt$suffix" +} + +# Parse git info +function git_prompt_info() { + if [[ -n $(git status -s 2> /dev/null |grep -v ^# |grep -v "working directory clean") ]]; 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 + commit_id=$(git rev-parse HEAD 2>/dev/null) || return + + echo -e "$prefix${REF_COLOR}${ref#refs/heads/}${DEFAULT_COLOR}:${commit_id:0:$MAX_GIT_HEX_LENGTH}$state$suffix" +} + +# Parse hg info +function hg_prompt_info() { + if [[ -n $(hg status 2> /dev/null) ]]; then + state=${HG_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} + else + state=${HG_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} + fi + prefix=${HG_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} + suffix=${HG_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} + branch=$(hg summary 2> /dev/null | grep branch | awk '{print $2}') + changeset=$(hg summary 2> /dev/null | grep parent | awk '{print $2}') + + echo -e "$prefix${REF_COLOR}${branch}${DEFAULT_COLOR}:${changeset#*:}$state$suffix" +} + +# Parse svn info +function svn_prompt_info() { + if [[ -n $(svn status --ignore-externals -q 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 + + revision=$(svn info 2> /dev/null | sed -ne 's#^Revision: ##p' ) + + echo -e "$prefix${REF_COLOR}$ref${DEFAULT_COLOR}:$revision$state$suffix" +} + +# Displays last X characters of pwd +function limited_pwd() { + + # Replace $HOME with ~ if possible + RELATIVE_PWD=${PWD/#$HOME/\~} + + local offset=$((${#RELATIVE_PWD}-$MAX_PWD_LENGTH)) + + if [ $offset -gt "0" ] + then + local truncated_symbol="..." + TRUNCATED_PWD=${RELATIVE_PWD:$offset:$MAX_PWD_LENGTH} + echo -e "${truncated_symbol}/${TRUNCATED_PWD#*/}" + else + echo -e "${RELATIVE_PWD}" + fi +} + +# Displays the current prompt +function prompt() { + local UC=$USER_COLOR + [ $UID -eq "0" ] && UC=$SUPERUSER_COLOR + + if [[ $VIRTUAL_PROMPT_ENABLED == 1 ]]; then + PS1="$(scm_char) ${UC}\u ${DEFAULT_COLOR}at ${MACHINE_COLOR}\h ${DEFAULT_COLOR}(${IP_COLOR}$(ip)${DEFAULT_COLOR}) in ${DIRECTORY_COLOR}$(limited_pwd)${DEFAULT_COLOR}$(virtual_prompt_info)$(scm_prompt_info)${reset_color} \$ " + else + PS1="$(scm_char) ${UC}\u ${DEFAULT_COLOR}at ${MACHINE_COLOR}\h ${DEFAULT_COLOR}(${IP_COLOR}$(ip)${DEFAULT_COLOR}) in ${DIRECTORY_COLOR}$(limited_pwd)${DEFAULT_COLOR}$(scm_prompt_info)${reset_color} \$ " + fi + PS2='> ' + PS4='+ ' +} + +PROMPT_COMMAND=prompt diff --git a/themes/modern-t/modern-t.theme.bash b/themes/modern-t/modern-t.theme.bash index 55da6e14..12e5b041 100644 --- a/themes/modern-t/modern-t.theme.bash +++ b/themes/modern-t/modern-t.theme.bash @@ -1,11 +1,11 @@ SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" -SCM_THEME_PROMPT_DIRTY=' ${bold_red}✗${normal}' -SCM_THEME_PROMPT_CLEAN=' ${bold_green}✓${normal}' -SCM_GIT_CHAR='${bold_green}±${normal}' -SCM_SVN_CHAR='${bold_cyan}⑆${normal}' -SCM_HG_CHAR='${bold_red}☿${normal}' +SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}" +SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}" +SCM_GIT_CHAR="${bold_green}±${normal}" +SCM_SVN_CHAR="${bold_cyan}⑆${normal}" +SCM_HG_CHAR="${bold_red}☿${normal}" case $TERM in xterm*) diff --git a/themes/modern/modern.theme.bash b/themes/modern/modern.theme.bash index 3efe9ffe..32c7cabb 100644 --- a/themes/modern/modern.theme.bash +++ b/themes/modern/modern.theme.bash @@ -1,11 +1,11 @@ SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" -SCM_THEME_PROMPT_DIRTY=' ${bold_red}✗${normal}' -SCM_THEME_PROMPT_CLEAN=' ${bold_green}✓${normal}' -SCM_GIT_CHAR='${bold_green}±${normal}' -SCM_SVN_CHAR='${bold_cyan}⑆${normal}' -SCM_HG_CHAR='${bold_red}☿${normal}' +SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}" +SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}" +SCM_GIT_CHAR="${bold_green}±${normal}" +SCM_SVN_CHAR="${bold_cyan}⑆${normal}" +SCM_HG_CHAR="${bold_red}☿${normal}" case $TERM in xterm*) diff --git a/themes/n0qorg/n0qorg.theme.bash b/themes/n0qorg/n0qorg.theme.bash index fcaca43f..2b9def6c 100644 --- a/themes/n0qorg/n0qorg.theme.bash +++ b/themes/n0qorg/n0qorg.theme.bash @@ -5,7 +5,11 @@ # host directory (branch*)» # for example: # ananas ~/Code/bash-it/themes (master*)» -PROMPT="${bold_blue}\[\$(hostname)\]${normal} \w${normal} ${bold_white}\[\$(git_prompt_info)\]${normal}» " +function prompt_command() { + PS1="${bold_blue}[$(hostname)]${normal} \w${normal} ${bold_white}[$(git_prompt_info)]${normal}» " +} + +PROMPT_COMMAND=prompt_command; ## git-theme # feel free to change git chars. diff --git a/themes/pete/pete.theme.bash b/themes/pete/pete.theme.bash index 95f243af..7b6702cf 100644 --- a/themes/pete/pete.theme.bash +++ b/themes/pete/pete.theme.bash @@ -5,7 +5,7 @@ prompt_setter() { history -a history -c history -r - PS1="(\t) $(scm_char) [\[$blue\]\u\[$reset_color\]@\[$green\]\H\[$reset_color\]] \[$yellow\]\w\[$reset_color\]$(scm_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='+ ' } diff --git a/themes/rainbowbrite/rainbowbrite.theme.bash b/themes/rainbowbrite/rainbowbrite.theme.bash new file mode 100644 index 00000000..e4424bbe --- /dev/null +++ b/themes/rainbowbrite/rainbowbrite.theme.bash @@ -0,0 +1,29 @@ +#!/bin/bash + +# based off of n0qorg +# looks like, if you're in a git repo: +# ± ~/path/to (branch ✓) $ +# in glorious red / blue / yellow color scheme + +prompt_setter() { + # Save history + history -a + history -c + history -r + # displays user@server in purple + # PS1="$red$(scm_char) $purple\u@\h$reset_color:$blue\w$yellow$(scm_prompt_info)$(rvm_version_prompt) $black\$$reset_color " + # no user@server + PS1="$red$(scm_char) $blue\w$yellow$(scm_prompt_info)$(rvm_version_prompt) $black\$$reset_color " + PS2='> ' + PS4='+ ' +} + +PROMPT_COMMAND=prompt_setter + +SCM_NONE_CHAR='·' +SCM_THEME_PROMPT_DIRTY=" ${red}✗" +SCM_THEME_PROMPT_CLEAN=" ${green}✓" +SCM_THEME_PROMPT_PREFIX=" (" +SCM_THEME_PROMPT_SUFFIX="${yellow})" +RVM_THEME_PROMPT_PREFIX=" (" +RVM_THEME_PROMPT_SUFFIX=")" diff --git a/themes/sirup/sirup.theme.bash b/themes/sirup/sirup.theme.bash index 50665871..146cc356 100644 --- a/themes/sirup/sirup.theme.bash +++ b/themes/sirup/sirup.theme.bash @@ -13,6 +13,10 @@ function rvm_version_prompt { [ "$full" != "" ] && echo "$full" } + +function prompt_command() { + # Check http://github.com/Sirupsen/dotfiles for screenshot + PS1="$blue\W/$bold_blue$(rvm_version_prompt)$bold_green$(__git_ps1 " (%s)") ${normal}$ " +} -# Check http://github.com/Sirupsen/dotfiles for screenshot -PS1='\[$blue\]\W/\[$bold_blue\]$(rvm_version_prompt)\[$bold_green\]$(__git_ps1 " (%s)") \[${normal}\]$ ' +PROMPT_COMMAND=prompt_command; diff --git a/themes/standard/standard.theme.bash b/themes/standard/standard.theme.bash index 5ba288c1..87402c73 100644 --- a/themes/standard/standard.theme.bash +++ b/themes/standard/standard.theme.bash @@ -1,7 +1,3 @@ -PROMPT='\[${green}\]\u\[${normal}\]@\[${green}\]\h\[${normal}\]:\[${blue}\]\w\[${normal}\]\[${red}\]$(prompt_char)$(git_prompt_info)\[${normal}\]\$ ' - - - # scm themeing SCM_THEME_PROMPT_DIRTY="×" SCM_THEME_PROMPT_CLEAN="✓" @@ -19,4 +15,10 @@ case $TERM in *) TITLEBAR="" ;; -esac \ No newline at end of file +esac + +function prompt_command() { + PROMPT='${green}\u${normal}@${green}\h${normal}:${blue}\w${normal}${red}$(prompt_char)$(git_prompt_info)${normal}\$ ' +} + +PROMPT_COMMAND=prompt_command; diff --git a/themes/zitron/zitron.theme.bash b/themes/zitron/zitron.theme.bash index c0726865..3ec4d97a 100644 --- a/themes/zitron/zitron.theme.bash +++ b/themes/zitron/zitron.theme.bash @@ -1,12 +1,6 @@ #!/bin/bash # zitron theme by Florian Baumann -## look-a-like -# user:host:pwd git-branch(*)$ -# for example: -# noqqe:deathstar:themes master*$ -PROMPT="${no_color}\u:\[\$(hostname)\]${normal}:${bold_yellow}\W/${normal} \[\$(git_prompt_info)\]${reset_color}$ " - ## git-theme # feel free to change git chars. GIT_THEME_PROMPT_DIRTY="${bold_yellow}*${normal}" @@ -18,3 +12,13 @@ GIT_THEME_PROMPT_SUFFIX="" # thanks a lot to http://geoff.greer.fm/lscolors/ export LSCOLORS="Gxfxcxdxbxegedabagacad" 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:" + +function prompt_command() { + ## look-a-like + # user:host:pwd git-branch(*)$ + # for example: + # noqqe:deathstar:themes master*$ + PS1="${no_color}\u:$(hostname)${normal}:${bold_yellow}\W/${normal} $(git_prompt_info)${reset_color}$ " +} + +PROMPT_COMMAND=prompt_command; diff --git a/themes/zork/zork.theme.bash b/themes/zork/zork.theme.bash index 54615d78..f541c0d9 100644 --- a/themes/zork/zork.theme.bash +++ b/themes/zork/zork.theme.bash @@ -1,11 +1,11 @@ SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" -SCM_THEME_PROMPT_DIRTY=' ${bold_red}✗${normal}' -SCM_THEME_PROMPT_CLEAN=' ${bold_green}✓${normal}' -SCM_GIT_CHAR='${bold_green}±${normal}' -SCM_SVN_CHAR='${bold_cyan}⑆${normal}' -SCM_HG_CHAR='${bold_red}☿${normal}' +SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}" +SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}" +SCM_GIT_CHAR="${bold_green}±${normal}" +SCM_SVN_CHAR="${bold_cyan}⑆${normal}" +SCM_HG_CHAR="${bold_red}☿${normal}" #Mysql Prompt export MYSQL_PS1="(\u@\h) [\d]> "