From 4261f3d8ecdc3e7cf400064d33907dc6f927b58b Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Tue, 13 Nov 2012 14:16:21 +0100 Subject: [PATCH 01/46] Added completion (show, help, enable, disable) for the bash-it function --- completion/available/bash-it.completion.bash | 135 +++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 completion/available/bash-it.completion.bash diff --git a/completion/available/bash-it.completion.bash b/completion/available/bash-it.completion.bash new file mode 100644 index 00000000..83ddfbc4 --- /dev/null +++ b/completion/available/bash-it.completion.bash @@ -0,0 +1,135 @@ +#!/usr/bin/env bash + +_bash-it-comp-enable-disable() +{ + local enable_disable_args="alias plugin completion" + COMPREPLY=( $(compgen -W "${enable_disable_args}" -- ${cur}) ) +} + +_bash-it-comp-list-available-not-enabled() +{ + subdirectory="$1" + + local available_things=$(for f in `ls -1 $BASH_IT/$subdirectory/available/*.bash`; + do + if [ ! -e $BASH_IT/$subdirectory/enabled/$(basename $f) ] + then + basename $f | cut -d'.' -f1 + fi + done) + + COMPREPLY=( $(compgen -W "all ${available_things}" -- ${cur}) ) +} + +_bash-it-comp-list-enabled() +{ + subdirectory="$1" + + local enabled_things=$(for f in `ls -1 $BASH_IT/$subdirectory/enabled/*.bash`; + do + basename $f | cut -d'.' -f1 + done) + + COMPREPLY=( $(compgen -W "all ${enabled_things}" -- ${cur}) ) +} + +_bash-it-comp-list-available() +{ + subdirectory="$1" + + local enabled_things=$(for f in `ls -1 $BASH_IT/$subdirectory/available/*.bash`; + do + basename $f | cut -d'.' -f1 + done) + + COMPREPLY=( $(compgen -W "${enabled_things}" -- ${cur}) ) +} + +_bash-it-comp() +{ + local cur prev opts prevprev + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + opts="help show enable disable" + + case "${prev}" in + show) + local show_args="plugins aliases completions" + COMPREPLY=( $(compgen -W "${show_args}" -- ${cur}) ) + return 0 + ;; + help) + local help_args="plugins aliases" + COMPREPLY=( $(compgen -W "${help_args}" -- ${cur}) ) + return 0 + ;; + enable) + _bash-it-comp-enable-disable + return 0 + ;; + disable) + _bash-it-comp-enable-disable + return 0 + ;; + aliases) + prevprev="${COMP_WORDS[COMP_CWORD-2]}" + + case "${prevprev}" in + help) + _bash-it-comp-list-available aliases + return 0 + ;; + esac + ;; + alias) + prevprev="${COMP_WORDS[COMP_CWORD-2]}" + + case "${prevprev}" in + enable) + _bash-it-comp-list-available-not-enabled aliases + return 0 + ;; + disable) + _bash-it-comp-list-enabled aliases + return 0 + ;; + esac + ;; + plugin) + prevprev="${COMP_WORDS[COMP_CWORD-2]}" + + case "${prevprev}" in + enable) + _bash-it-comp-list-available-not-enabled plugins + return 0 + ;; + disable) + _bash-it-comp-list-enabled plugins + return 0 + ;; + esac + ;; + completion) + prevprev="${COMP_WORDS[COMP_CWORD-2]}" + + case "${prevprev}" in + enable) + _bash-it-comp-list-available-not-enabled completion + return 0 + ;; + disable) + _bash-it-comp-list-enabled completion + return 0 + ;; + esac + ;; + esac + + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + + return 0 +} + +complete -F _bash-it-comp bash-it From 20b3d43c4bd8194fd3d4333ae392c755efb28112 Mon Sep 17 00:00:00 2001 From: Greg Nofi Date: Thu, 15 Nov 2012 10:14:45 -0500 Subject: [PATCH 02/46] Git Aliases: Remove duplicate darwin clause/add default clause for git diff. --- aliases/available/git.aliases.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index bbac313b..58411d81 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -35,7 +35,7 @@ case $OSTYPE in darwin*) alias gd='git diff | mate' ;; - darwin*) + *) alias gd='git diff' ;; esac From 8c4ea4f5988b7d758be9f891943b2d3cfd2639e5 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Thu, 15 Nov 2012 10:24:01 -0600 Subject: [PATCH 03/46] Add ability to override using $EDITOR --- aliases/available/git.aliases.bash | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index 58411d81..75b8f65c 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -28,14 +28,18 @@ alias gdel='git branch -D' alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/master' alias gll='git log --graph --pretty=oneline --abbrev-commit' -case $OSTYPE in - linux*) - alias gd='git diff | vim -R -' - ;; - darwin*) - alias gd='git diff | mate' - ;; - *) - alias gd='git diff' - ;; -esac +if [ -z "$EDITOR" ]; then + case $OSTYPE in + linux*) + alias gd='git diff | vim -R -' + ;; + darwin*) + alias gd='git diff | mate' + ;; + *) + alias gd='git diff' + ;; + esac +else + alias gd="git diff | $EDITOR" +fi From afe700fc0c3dee052db04645ccf62fadcc2ccc40 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Fri, 16 Nov 2012 11:00:30 -0600 Subject: [PATCH 04/46] Remove --no-site-packages as that is now the default behavior --- plugins/available/virtualenv.plugin.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/available/virtualenv.plugin.bash b/plugins/available/virtualenv.plugin.bash index 302e19d2..c2c2f915 100644 --- a/plugins/available/virtualenv.plugin.bash +++ b/plugins/available/virtualenv.plugin.bash @@ -11,7 +11,7 @@ function mkvenv { group 'virtualenv' cwd=`basename \`pwd\`` - mkvirtualenv --no-site-packages --distribute $cwd + mkvirtualenv --distribute $cwd } @@ -19,7 +19,7 @@ function mkvbranch { about 'create a new virtualenv for the current branch' group 'virtualenv' - mkvirtualenv --no-site-packages --distribute "$(basename `pwd`)@$(git_prompt_info)" + mkvirtualenv --distribute "$(basename `pwd`)@$(git_prompt_info)" } function wovbranch { From 2813930e0438261a2e3fc13d9b4f93ce421f4b71 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Fri, 16 Nov 2012 11:00:46 -0600 Subject: [PATCH 05/46] Add a wovenv to match mkvenv --- plugins/available/virtualenv.plugin.bash | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/available/virtualenv.plugin.bash b/plugins/available/virtualenv.plugin.bash index c2c2f915..93578395 100644 --- a/plugins/available/virtualenv.plugin.bash +++ b/plugins/available/virtualenv.plugin.bash @@ -28,3 +28,10 @@ function wovbranch { workon "$(basename `pwd`)@$(git_prompt_info)" } + +function wovenv { + about 'works on the virtualenv for this directory' + group 'virtualenv' + + workon "$(basename `pwd`)" +} From f93feb6e016195306113ce56f7cde7604aa5900f Mon Sep 17 00:00:00 2001 From: manojlds Date: Thu, 14 Feb 2013 10:38:12 +0530 Subject: [PATCH 06/46] Using $VIRTUAL_ENV to set virtualenv prompt --- themes/base.theme.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index f096fda4..18c6c9d4 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -137,8 +137,8 @@ function ruby_version_prompt { } function virtualenv_prompt { - if which virtualenv &> /dev/null; then - virtualenv=$([ ! -z "$VIRTUAL_ENV" ] && echo "`basename $VIRTUAL_ENV`") || return + if [[ -n "$VIRTUAL_ENV" ]]; then + virtualenv=`basename "$VIRTUAL_ENV"` echo -e "$VIRTUALENV_THEME_PROMPT_PREFIX$virtualenv$VIRTUALENV_THEME_PROMPT_SUFFIX" fi } From 1d1c57265c1d660e9e5c6e6f13d8cd7e1707fa08 Mon Sep 17 00:00:00 2001 From: Sebastian Pauka Date: Thu, 7 Mar 2013 10:17:01 +1100 Subject: [PATCH 07/46] Fixed ls alias to use --color=auto instead of --color=always. --- aliases/available/general.aliases.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aliases/available/general.aliases.bash b/aliases/available/general.aliases.bash index 3e87e2dc..c3aefe96 100644 --- a/aliases/available/general.aliases.bash +++ b/aliases/available/general.aliases.bash @@ -13,7 +13,7 @@ alias _="sudo" if [ $(uname) = "Linux" ] then - alias ls="ls --color=always" + alias ls="ls --color=auto" fi which gshuf &> /dev/null if [ $? -eq 1 ] From f2dcd4e759f2ca0b90a3c0a4f372b895b93a500e Mon Sep 17 00:00:00 2001 From: Fizer Khan Date: Sat, 9 Mar 2013 12:39:52 +0530 Subject: [PATCH 08/46] Added Jitsu aliases. --- aliases/available/jitsu.aliases.bash | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 aliases/available/jitsu.aliases.bash diff --git a/aliases/available/jitsu.aliases.bash b/aliases/available/jitsu.aliases.bash new file mode 100644 index 00000000..91e96849 --- /dev/null +++ b/aliases/available/jitsu.aliases.bash @@ -0,0 +1,49 @@ +cite 'about-alias' +about-alias 'jitsu task abbreviations' + +# jitsu +alias j='jitsu' +alias jl='jitsu login' +alias jo='jitsu logout' + +# deploy and update +alias jd='jitsu apps deploy' +alias ju='jitsu apps update' + +# new and start, restart, stop +alias jn='jitsu apps create' +alias js='jitsu apps start' +alias jr='jitsu apps restart' +alias jx='jitsu apps stop' + +# logs +alias jll='jitsu logs' +alias jlog='jitsu logs' +alias jlogs='jitsu logs' + +# env +alias je='jitsu env' +alias jel='jitsu env list' +alias jes='jitsu env set' +alias jeg='jitsu env get' +alias jed='jitsu env delete' +alias jec='jitsu env clear' +alias jesv='jitsu env save' +alias jeld='jitsu env load' + +# configuration +alias jc='jitsu conf' +alias jcl='jitsu config list' +alias jcs='jitsu config set' +alias jcg='jitsu config get' +alias jcd='jitsu config delete' + +# list and install, view +alias jls='jitsu list' +alias jin='jitsu install' +alias jv='jitsu apps view' + +# Database, Snapshots and Tokens +alias jdb='jitsu databases' +alias jss='jitsu snapshots' +alias jto='jitsu tokens' From e9c9049b2285606da1a167a9d75b9c9fe1d1e24b Mon Sep 17 00:00:00 2001 From: Robbie Clutton Date: Sun, 10 Mar 2013 09:05:36 +0000 Subject: [PATCH 09/46] 'git pull --rebase' alias --- aliases/available/git.aliases.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index 75b8f65c..40919f36 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -11,6 +11,7 @@ alias gst='git status' alias gs='git status' alias gss='git status -s' alias gl='git pull' +alias gpr='git pull --rebase' alias gup='git fetch && git rebase' alias gp='git push' alias gpo='git push origin' From 75dbdaf2742d874f8254cd908db36808eb890fe2 Mon Sep 17 00:00:00 2001 From: Dave Paroulek Date: Mon, 25 Mar 2013 08:36:27 -0400 Subject: [PATCH 10/46] Create plugins/enabled directory if it doesn't already exist - This fixes a bug I saw after installing bash-it on Mac OS X 10.6.8. During bash-it installation I chose not to install any plugins. After install, when `bash-it enable plugin foo` was complaining that the enabled directory did not exist. --- lib/helpers.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/helpers.bash b/lib/helpers.bash index e1787fe0..b99ae3d3 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -277,6 +277,8 @@ _enable-thing () return fi + mkdir -p $BASH_IT/$subdirectory/enabled + ln -s $BASH_IT/$subdirectory/available/$plugin $BASH_IT/$subdirectory/enabled/$plugin fi From 0cfec65383e542f165132c9f8983ebfb666f1b62 Mon Sep 17 00:00:00 2001 From: Mark Rickert Date: Tue, 9 Apr 2013 09:14:40 -0400 Subject: [PATCH 11/46] Added OSX utility shortcuts .DS_Store cleaner (recursive) See who's connected to your itunes library Flush dns cache. --- aliases/available/osx.aliases.bash | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/aliases/available/osx.aliases.bash b/aliases/available/osx.aliases.bash index e234727d..3d82b500 100644 --- a/aliases/available/osx.aliases.bash +++ b/aliases/available/osx.aliases.bash @@ -23,3 +23,12 @@ fi # Requires growlnotify, which can be found in the Growl DMG under "Extras" alias grnot='growlnotify -s -t Terminal -m "Done"' + +# Get rid of those pesky .DS_Store files recursively +alias dsclean='find . -type f -name .DS_Store -print0 | xargs -0 rm' + +# Track who is listening to your iTunes music +alias whotunes='lsof -r 2 -n -P -F n -c iTunes -a -i TCP@`hostname`:3689' + +# Flush your dns cache +alias flush='dscacheutil -flushcache' From 8be156fc8b3e1d5ebd2268781a91335fb6c850dd Mon Sep 17 00:00:00 2001 From: Mark Rickert Date: Tue, 9 Apr 2013 09:15:48 -0400 Subject: [PATCH 12/46] Added some awesome git aliases for statistics, history, and seeing what changed. --- aliases/available/git.aliases.bash | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index 75b8f65c..9a9a1060 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -11,6 +11,7 @@ alias gst='git status' alias gs='git status' alias gss='git status -s' alias gl='git pull' +alias gpp='git pull && git push' alias gup='git fetch && git rebase' alias gp='git push' alias gpo='git push origin' @@ -27,6 +28,10 @@ alias gexport='git archive --format zip --output' alias gdel='git branch -D' alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/master' alias gll='git log --graph --pretty=oneline --abbrev-commit' +alias gg="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative" +alias ggs="gg --stat" +alias gsl="git shortlog -sn" +alias gw="git whatchanged" if [ -z "$EDITOR" ]; then case $OSTYPE in From 70e4ac9e553c37a3595643c3cd3ebc22406e955b Mon Sep 17 00:00:00 2001 From: Conrado Buhrer Date: Wed, 10 Apr 2013 13:57:21 -0300 Subject: [PATCH 13/46] fixed: hg branch grep+awk problem #197 --- themes/base.theme.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 18c6c9d4..5a5edd32 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -108,8 +108,8 @@ function hg_prompt_vars { fi SCM_PREFIX=${HG_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} SCM_SUFFIX=${HG_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} - SCM_BRANCH=$(hg summary 2> /dev/null | grep branch | awk '{print $2}') - SCM_CHANGE=$(hg summary 2> /dev/null | grep parent | awk '{print $2}') + SCM_BRANCH=$(hg summary 2> /dev/null | grep branch: | awk '{print $2}') + SCM_CHANGE=$(hg summary 2> /dev/null | grep parent: | awk '{print $2}') } function rvm_version_prompt { From 9dec4920237c4d40955789b66dbe72fa8e62c428 Mon Sep 17 00:00:00 2001 From: Sasha Gerrand Date: Wed, 24 Apr 2013 13:05:28 +1000 Subject: [PATCH 14/46] Adds write permission test on ~/.bash_profile prior to backup attempt. Fixes #199. --- install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 0f1da39c..46edcf22 100755 --- a/install.sh +++ b/install.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash BASH_IT="$HOME/.bash_it" -cp $HOME/.bash_profile $HOME/.bash_profile.bak - -echo "Your original .bash_profile has been backed up to .bash_profile.bak" +test -w $HOME/.bash_profile && + cp $HOME/.bash_profile $HOME/.bash_profile.bak && + echo "Your original .bash_profile has been backed up to .bash_profile.bak" cp $HOME/.bash_it/template/bash_profile.template.bash $HOME/.bash_profile From ce5bb3d6eb85ccb919cf72d911b36bae2bc9736b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarjei=20Hus=C3=B8y?= Date: Wed, 1 May 2013 21:33:52 +0300 Subject: [PATCH 15/46] Fix typo in general.aliases.bash. --- aliases/available/general.aliases.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aliases/available/general.aliases.bash b/aliases/available/general.aliases.bash index c3aefe96..2439eb08 100644 --- a/aliases/available/general.aliases.bash +++ b/aliases/available/general.aliases.bash @@ -40,7 +40,7 @@ alias piano='pianobar' alias ..='cd ..' # Go up one directory alias ...='cd ../..' # Go up two directories -alias ....='cd ../../..' # Go up two directories +alias ....='cd ../../..' # Go up three directories alias -- -='cd -' # Go back # Shell History From b9f7a817a439397f50f922f5a206ebae6f487aa6 Mon Sep 17 00:00:00 2001 From: Ken Sheedlo Date: Wed, 22 May 2013 00:37:24 -0600 Subject: [PATCH 16/46] Add pip completion --- completion/available/pip.completion.bash | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 completion/available/pip.completion.bash diff --git a/completion/available/pip.completion.bash b/completion/available/pip.completion.bash new file mode 100644 index 00000000..ad3abb7e --- /dev/null +++ b/completion/available/pip.completion.bash @@ -0,0 +1,11 @@ + +# pip bash completion start +_pip_completion() +{ + COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \ + COMP_CWORD=$COMP_CWORD \ + PIP_AUTO_COMPLETE=1 $1 ) ) +} +complete -o default -F _pip_completion pip +# pip bash completion end + From 9933aa145fca893858e668ff1e11f5123c6944a7 Mon Sep 17 00:00:00 2001 From: magnus Date: Tue, 20 Aug 2013 21:46:09 +0200 Subject: [PATCH 17/46] Add Bakke theme --- themes/bakke/bakke.theme.bash | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 themes/bakke/bakke.theme.bash diff --git a/themes/bakke/bakke.theme.bash b/themes/bakke/bakke.theme.bash new file mode 100644 index 00000000..3663bc17 --- /dev/null +++ b/themes/bakke/bakke.theme.bash @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +SCM_THEME_PROMPT_DIRTY=" ${red}✗" +SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" +SCM_THEME_PROMPT_PREFIX=" |" +SCM_THEME_PROMPT_SUFFIX="${green}|" + +GIT_THEME_PROMPT_DIRTY=" ${red}✗" +GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓" +GIT_THEME_PROMPT_PREFIX=" ${green}|" +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}$(ruby_version_prompt) ${yellow}\h ${reset_color}in ${green}\w ${reset_color}\n${green}→${reset_color} " + #PS1="\n${purple}\h: ${reset_color} ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}→${reset_color} " + #PS1="\n${cyan}\h: ${reset_color} ${yellow}\w\n${red}$(scm_char)${red}$(scm_prompt_info) ${green}→${reset_color} " + PS1="\n${cyan}\h: ${reset_color} ${yellow}\w ${green}$(scm_prompt_info)\n${reset_color}→ " +} + +PROMPT_COMMAND=prompt_command; From 8c7b07917b507e4154191f18a00d28f327fd9048 Mon Sep 17 00:00:00 2001 From: oddjobsman Date: Tue, 17 Sep 2013 19:04:50 +0530 Subject: [PATCH 18/46] Added Sexy Bash Prompt suggested by @addyosmani in "A Toolbelt For The Modern WebApp Developer" as bash-it theme. --- themes/sexy/sexy.theme.bash | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 themes/sexy/sexy.theme.bash diff --git a/themes/sexy/sexy.theme.bash b/themes/sexy/sexy.theme.bash new file mode 100644 index 00000000..949dcca4 --- /dev/null +++ b/themes/sexy/sexy.theme.bash @@ -0,0 +1,43 @@ +# Sexy Bash Prompt, inspired by "Extravagant Zsh Prompt" +# Screenshot: http://cloud.gf3.ca/M5rG +# A big thanks to \amethyst on Freenode + +if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then export TERM=gnome-256color +elif [[ $TERM != dumb ]] && infocmp xterm-256color >/dev/null 2>&1; then export TERM=xterm-256color +fi + +if tput setaf 1 &> /dev/null; then + tput sgr0 + if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then + MAGENTA=$(tput setaf 9) + ORANGE=$(tput setaf 172) + GREEN=$(tput setaf 190) + PURPLE=$(tput setaf 141) + WHITE=$(tput setaf 0) + else + MAGENTA=$(tput setaf 5) + ORANGE=$(tput setaf 4) + GREEN=$(tput setaf 2) + PURPLE=$(tput setaf 1) + WHITE=$(tput setaf 7) + fi + BOLD=$(tput bold) + RESET=$(tput sgr0) +else + MAGENTA="\033[1;31m" + ORANGE="\033[1;33m" + GREEN="\033[1;32m" + PURPLE="\033[1;35m" + WHITE="\033[1;37m" + BOLD="" + RESET="\033[m" +fi + +parse_git_dirty () { + [[ $(git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*" +} +parse_git_branch () { + git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" +} + +PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]" From 8c03cc4297aa77ed6d7d5b5f715ee856fb951b71 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Wed, 2 Oct 2013 16:41:17 -0500 Subject: [PATCH 19/46] Updated README.md to fix #230 Thanks @p5k6! --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 105d5be7..527034c4 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Includes autocompletion, themes, aliases, custom functions, a few stolen pieces ## Install -1. Check a clone of this repo: `git clone http://github.com/revans/bash-it.git ~/.bash_it` +1. Check a clone of this repo: `git clone https://github.com/revans/bash-it.git ~/.bash_it` 2. Run `~/.bash_it/install.sh` (it automatically backs up your `~/.bash_profile`) 3. Edit your `~/.bash_profile` file in order to customize bash-it. From b48a0f2f65c2fa9cf12e8786aa19308a9109dc8e Mon Sep 17 00:00:00 2001 From: aram price Date: Sun, 3 Nov 2013 17:58:09 -0800 Subject: [PATCH 20/46] Add chruby and chruby-auto plugins * chruby.bash loads chruby * chruby-auto.bash loads chruby and enables auto-switching * add chruby_version_prompt() function for displaying ruby version * inspired by https://gist.github.com/rssvihla/6153455 --- plugins/available/chruby-auto.bash | 5 +++++ plugins/available/chruby.bash | 4 ++++ themes/base.theme.bash | 12 +++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 plugins/available/chruby-auto.bash create mode 100644 plugins/available/chruby.bash diff --git a/plugins/available/chruby-auto.bash b/plugins/available/chruby-auto.bash new file mode 100644 index 00000000..49efc503 --- /dev/null +++ b/plugins/available/chruby-auto.bash @@ -0,0 +1,5 @@ +cite about-plugin +about-plugin 'load chruby + auto-switching (from /usr/local/share/chruby)' + +source /usr/local/share/chruby/chruby.sh +source /usr/local/share/chruby/auto.sh diff --git a/plugins/available/chruby.bash b/plugins/available/chruby.bash new file mode 100644 index 00000000..c6793478 --- /dev/null +++ b/plugins/available/chruby.bash @@ -0,0 +1,4 @@ +cite about-plugin +about-plugin 'load chruby (from /usr/local/share/chruby)' + +source /usr/local/share/chruby/chruby.sh diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 5a5edd32..001ca65a 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -132,8 +132,18 @@ function rbfu_version_prompt { fi } +function chruby_version_prompt { + if declare -f -F chruby &> /dev/null; then + if declare -f -F chruby_auto &> /dev/null; then + chruby_auto + fi + chruby=$(ruby --version | awk '{print $1, $2;}') || return + echo -e "$CHRUBY_THEME_PROMPT_PREFIX$chruby$CHRUBY_THEME_PROMPT_SUFFIX" + fi +} + function ruby_version_prompt { - echo -e "$(rbfu_version_prompt)$(rbenv_version_prompt)$(rvm_version_prompt)" + echo -e "$(rbfu_version_prompt)$(rbenv_version_prompt)$(rvm_version_prompt)$(chruby_version_prompt)" } function virtualenv_prompt { From 460382a4e1351bca0d2a1dfab82295e0b100e206 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Thu, 7 Nov 2013 14:08:42 +0100 Subject: [PATCH 21/46] Added custom bash prompt, based on the 'my' theme. This colors the arrow at the start of the second line based on the exit code of the last command: green for 0, red for non-zero This functionality currently fails when the 'fasd' plugin is enabled, since it is messing with the PROMPT_COMMAND function. --- themes/nwinkler/nwinkler.theme.bash | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 themes/nwinkler/nwinkler.theme.bash diff --git a/themes/nwinkler/nwinkler.theme.bash b/themes/nwinkler/nwinkler.theme.bash new file mode 100644 index 00000000..b8bcc226 --- /dev/null +++ b/themes/nwinkler/nwinkler.theme.bash @@ -0,0 +1,47 @@ +#!/bin/bash + +# Two line prompt showing the following information: +# (time) SCM [username@hostname] pwd (SCM branch SCM status) +# → +# +# Example: +# (14:00:26) ± [foo@bar] ~/.bash_it (master ✓) +# → +# +# The arrow on the second line is showing the exit status of the last command: +# * Green: 0 exit status +# * Red: non-zero exit status +# +# The exit code functionality currently doesn't work if you are using the 'fasd' plugin, +# since 'fasd' is messing with the $PROMPT_COMMAND + + +PROMPT_END_CLEAN="${green}→${reset_color}" +PROMPT_END_DIRTY="${red}→${reset_color}" + +function prompt_end() { + echo -e "$PROMPT_END" +} + +prompt_setter() { + local exit_status=$? + if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN + else PROMPT_END=$PROMPT_END_DIRTY + fi + # Save history + 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) ${reset_color}\n$(prompt_end) " + PS2='> ' + PS4='+ ' +} + +PROMPT_COMMAND=prompt_setter + +SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}" +SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}" +SCM_THEME_PROMPT_PREFIX=" (" +SCM_THEME_PROMPT_SUFFIX=")" +RVM_THEME_PROMPT_PREFIX=" (" +RVM_THEME_PROMPT_SUFFIX=")" From 38575181da716e92e6ed737af2ae02bd0b7e73c0 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Tue, 12 Nov 2013 23:54:07 +0100 Subject: [PATCH 22/46] Added support to show commits ahead, commits behind and stashes count in Git through variables --- themes/base.theme.bash | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 001ca65a..96c7cf00 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -70,18 +70,28 @@ function scm_prompt_info { } function git_prompt_vars { - if [[ -n $(git status -s 2> /dev/null |grep -v ^# |grep -v "working directory clean") ]]; then + SCM_GIT_AHEAD='' + SCM_GIT_BEHIND='' + SCM_GIT_STASH='' + local status="$(git status -bs --porcelain 2> /dev/null)" + if [[ -n "$(grep -v ^# <<< "${status}")" ]]; then SCM_DIRTY=1 - SCM_STATE=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} + SCM_STATE=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} else SCM_DIRTY=0 - SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} + SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} fi SCM_PREFIX=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} SCM_SUFFIX=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} local ref=$(git symbolic-ref HEAD 2> /dev/null) SCM_BRANCH=${ref#refs/heads/} SCM_CHANGE=$(git rev-parse HEAD 2>/dev/null) + local ahead_re='.+ahead ([0-9]+).+' + local behind_re='.+behind ([0-9]+).+' + [[ "${status}" =~ ${ahead_re} ]] && SCM_GIT_AHEAD=" ${SCM_GIT_AHEAD_CHAR}${BASH_REMATCH[1]}" + [[ "${status}" =~ ${behind_re} ]] && SCM_GIT_BEHIND=" ${SCM_GIT_BEHIND_CHAR}${BASH_REMATCH[1]}" + local stash_count="$(git stash list | wc -l)" + [[ "${stash_count}" -gt 0 ]] && SCM_GIT_STASH=" {${stash_count}}" } function svn_prompt_vars { From 68dc6768c8be6b03975ff02dfcf4111999979f22 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Wed, 13 Nov 2013 00:01:09 +0100 Subject: [PATCH 23/46] Added Powerline theme --- themes/powerline/powerline.theme.bash | 100 ++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 themes/powerline/powerline.theme.bash diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash new file mode 100644 index 00000000..3d0bf80e --- /dev/null +++ b/themes/powerline/powerline.theme.bash @@ -0,0 +1,100 @@ +#!/usr/bin/env bash + +THEME_PROMPT_SEPARATOR="" + +SHELL_SSH_CHAR=" " +SHELL_THEME_PROMPT_COLOR=32 +SHELL_SSH_THEME_PROMPT_COLOR=208 + +VIRTUALENV_CHAR="ⓔ " +VIRTUALENV_THEME_PROMPT_COLOR=35 + +SCM_NONE_CHAR="" +SCM_GIT_CHAR=" " +SCM_GIT_BEHIND_CHAR="↓" +SCM_GIT_AHEAD_CHAR="↑" +SCM_THEME_PROMPT_CLEAN="" +SCM_THEME_PROMPT_DIRTY="" +SCM_THEME_PROMPT_COLOR=238 +SCM_THEME_PROMPT_CLEAN_COLOR=267 +SCM_THEME_PROMPT_DIRTY_COLOR=220 + +CWD_THEME_PROMPT_COLOR=240 + +LAST_STATUS_THEME_PROMPT_COLOR=52 + +function set_rgb_color { + if [[ "${1}" != "-" ]]; then + fg="38;5;${1}" + fi + if [[ "${2}" != "-" ]]; then + bg="48;5;${2}" + [[ -n "${fg}" ]] && bg=";${bg}" + fi + echo -e "\[\033[${fg}${bg}m\]" +} + +function powerline_shell_prompt { + if [[ -n "${SSH_CLIENT}" ]]; then + SHELL_PROMPT="${bold_white}$(set_rgb_color - ${SHELL_SSH_THEME_PROMPT_COLOR}) ${SHELL_SSH_CHAR}\u@\h ${normal}" + LAST_THEME_COLOR=${SHELL_SSH_THEME_PROMPT_COLOR} + else + SHELL_PROMPT="${bold_white}$(set_rgb_color - ${SHELL_THEME_PROMPT_COLOR}) \u ${normal}" + LAST_THEME_COLOR=${SHELL_THEME_PROMPT_COLOR} + fi +} + +function powerline_virtualenv_prompt { + if [[ -n "$VIRTUAL_ENV" ]]; then + virtualenv=$(basename "$VIRTUAL_ENV") + VIRTUALENV_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${VIRTUALENV_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${VIRTUALENV_THEME_PROMPT_COLOR}) ${VIRTUALENV_CHAR}$virtualenv ${normal}" + LAST_THEME_COLOR=${VIRTUALENV_THEME_PROMPT_COLOR} + else + VIRTUALENV_PROMPT="" + fi +} + +function powerline_scm_prompt { + scm_prompt_vars + + if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then + if [[ "${SCM_DIRTY}" -eq 1 ]]; then + SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_DIRTY_COLOR} ${SCM_THEME_PROMPT_COLOR})" + else + SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_CLEAN_COLOR} ${SCM_THEME_PROMPT_COLOR})" + fi + [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]] && SCM_PROMPT+=" ${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}${SCM_GIT_BEHIND}${SCM_GIT_AHEAD}${SCM_GIT_STASH}" + SCM_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${SCM_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${SCM_PROMPT} ${normal}" + LAST_THEME_COLOR=${SCM_THEME_PROMPT_COLOR} + else + SCM_PROMPT="" + fi +} + +function powerline_cwd_prompt { + CWD_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${CWD_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${CWD_THEME_PROMPT_COLOR}) \w ${normal}$(set_rgb_color ${CWD_THEME_PROMPT_COLOR} -)${normal}" + LAST_THEME_COLOR=${CWD_THEME_PROMPT_COLOR} +} + +function powerline_last_status_prompt { + if [[ "$1" -eq 0 ]]; then + LAST_STATUS_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}" + else + LAST_STATUS_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${LAST_STATUS_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${LAST_STATUS_THEME_PROMPT_COLOR}) ${LAST_STATUS} ${normal}$(set_rgb_color ${LAST_STATUS_THEME_PROMPT_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}" + fi +} + +function powerline_prompt_command() { + local LAST_STATUS="$?" + + powerline_shell_prompt + powerline_virtualenv_prompt + powerline_scm_prompt + powerline_cwd_prompt + powerline_last_status_prompt LAST_STATUS + + PS1="${SHELL_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} " +} + +PROMPT_COMMAND=powerline_prompt_command + From 96b370ad0690e0230ba0a8560815429e9a3ec610 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Wed, 13 Nov 2013 22:45:05 +0100 Subject: [PATCH 24/46] Added Powerline-plain theme --- .../powerline-plain.theme.bash | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 themes/powerline-plain/powerline-plain.theme.bash diff --git a/themes/powerline-plain/powerline-plain.theme.bash b/themes/powerline-plain/powerline-plain.theme.bash new file mode 100644 index 00000000..ada23dcc --- /dev/null +++ b/themes/powerline-plain/powerline-plain.theme.bash @@ -0,0 +1,93 @@ +#!/usr/bin/env bash + +SHELL_SSH_CHAR="⌁ " +SHELL_THEME_PROMPT_COLOR=32 +SHELL_SSH_THEME_PROMPT_COLOR=208 + +VIRTUALENV_CHAR="ⓔ " +VIRTUALENV_THEME_PROMPT_COLOR=35 + +SCM_NONE_CHAR="" +SCM_GIT_CHAR="⎇ " +SCM_GIT_BEHIND_CHAR="↓" +SCM_GIT_AHEAD_CHAR="↑" +SCM_THEME_PROMPT_CLEAN="" +SCM_THEME_PROMPT_DIRTY="" +SCM_THEME_PROMPT_COLOR=238 +SCM_THEME_PROMPT_CLEAN_COLOR=267 +SCM_THEME_PROMPT_DIRTY_COLOR=220 + +CWD_THEME_PROMPT_COLOR=240 + +LAST_STATUS_THEME_PROMPT_COLOR=52 + +function set_rgb_color { + if [[ "${1}" != "-" ]]; then + fg="38;5;${1}" + fi + if [[ "${2}" != "-" ]]; then + bg="48;5;${2}" + [[ -n "${fg}" ]] && bg=";${bg}" + fi + echo -e "\[\033[${fg}${bg}m\]" +} + +function powerline_shell_prompt { + if [[ -n "${SSH_CLIENT}" ]]; then + SHELL_PROMPT="${bold_white}$(set_rgb_color - ${SHELL_SSH_THEME_PROMPT_COLOR}) ${SHELL_SSH_CHAR}\u@\h ${normal}" + else + SHELL_PROMPT="${bold_white}$(set_rgb_color - ${SHELL_THEME_PROMPT_COLOR}) \u ${normal}" + fi +} + +function powerline_virtualenv_prompt { + if [[ -n "$VIRTUAL_ENV" ]]; then + virtualenv=$(basename "$VIRTUAL_ENV") + VIRTUALENV_PROMPT="$(set_rgb_color - ${VIRTUALENV_THEME_PROMPT_COLOR}) ${VIRTUALENV_CHAR}$virtualenv ${normal}" + else + VIRTUALENV_PROMPT="" + fi +} + +function powerline_scm_prompt { + scm_prompt_vars + + if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then + if [[ "${SCM_DIRTY}" -eq 1 ]]; then + SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_DIRTY_COLOR} ${SCM_THEME_PROMPT_COLOR})" + else + SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_CLEAN_COLOR} ${SCM_THEME_PROMPT_COLOR})" + fi + [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]] && SCM_PROMPT+=" ${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}${SCM_GIT_BEHIND}${SCM_GIT_AHEAD}${SCM_GIT_STASH}" + SCM_PROMPT="${SCM_PROMPT} ${normal}" + else + SCM_PROMPT="" + fi +} + +function powerline_cwd_prompt { + CWD_PROMPT="${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${CWD_THEME_PROMPT_COLOR}) \w ${normal}$(set_rgb_color ${CWD_THEME_PROMPT_COLOR} -)${normal}" +} + +function powerline_last_status_prompt { + if [[ "$1" -eq 0 ]]; then + LAST_STATUS_PROMPT="" + else + LAST_STATUS_PROMPT="$(set_rgb_color - ${LAST_STATUS_THEME_PROMPT_COLOR}) ${LAST_STATUS} ${normal}$(set_rgb_color ${LAST_STATUS_THEME_PROMPT_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}" + fi +} + +function powerline_prompt_command() { + local LAST_STATUS="$?" + + powerline_shell_prompt + powerline_virtualenv_prompt + powerline_scm_prompt + powerline_cwd_prompt + powerline_last_status_prompt LAST_STATUS + + PS1="${SHELL_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} " +} + +PROMPT_COMMAND=powerline_prompt_command + From 85314e395cccccd4a49948f222e48c1fcf5fb375 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Fri, 8 Nov 2013 09:48:15 +0100 Subject: [PATCH 25/46] Added first version of git-svn aliases --- aliases/available/gitsvn.aliases.bash | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 aliases/available/gitsvn.aliases.bash diff --git a/aliases/available/gitsvn.aliases.bash b/aliases/available/gitsvn.aliases.bash new file mode 100644 index 00000000..feb608be --- /dev/null +++ b/aliases/available/gitsvn.aliases.bash @@ -0,0 +1,7 @@ +cite 'about-alias' +about-alias 'common git-svn abbreviations' + +# Aliases +alias gsr='git svn rebase' +alias gsc='git svn dcommit' +alias gsi='git svn info' From ca0d29e2afcc45a1b0bb50139085423dcd4457c1 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Fri, 15 Nov 2013 17:57:05 +0100 Subject: [PATCH 26/46] Fixed wrong number for white color in Powerline and Powerline-plain themes --- themes/powerline-plain/powerline-plain.theme.bash | 2 +- themes/powerline/powerline.theme.bash | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/powerline-plain/powerline-plain.theme.bash b/themes/powerline-plain/powerline-plain.theme.bash index ada23dcc..04ce6846 100644 --- a/themes/powerline-plain/powerline-plain.theme.bash +++ b/themes/powerline-plain/powerline-plain.theme.bash @@ -14,7 +14,7 @@ SCM_GIT_AHEAD_CHAR="↑" SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_COLOR=238 -SCM_THEME_PROMPT_CLEAN_COLOR=267 +SCM_THEME_PROMPT_CLEAN_COLOR=255 SCM_THEME_PROMPT_DIRTY_COLOR=220 CWD_THEME_PROMPT_COLOR=240 diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash index 3d0bf80e..815e92cc 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -16,7 +16,7 @@ SCM_GIT_AHEAD_CHAR="↑" SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_COLOR=238 -SCM_THEME_PROMPT_CLEAN_COLOR=267 +SCM_THEME_PROMPT_CLEAN_COLOR=255 SCM_THEME_PROMPT_DIRTY_COLOR=220 CWD_THEME_PROMPT_COLOR=240 From 91538bce78cb98c15ef9537ce1888f8bcdacf0bb Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Fri, 15 Nov 2013 20:57:27 +0100 Subject: [PATCH 27/46] Now, really fixed wrong number for white color in Powerline and Powerline-plain themes --- themes/powerline-plain/powerline-plain.theme.bash | 2 +- themes/powerline/powerline.theme.bash | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/powerline-plain/powerline-plain.theme.bash b/themes/powerline-plain/powerline-plain.theme.bash index 04ce6846..4a83513b 100644 --- a/themes/powerline-plain/powerline-plain.theme.bash +++ b/themes/powerline-plain/powerline-plain.theme.bash @@ -14,7 +14,7 @@ SCM_GIT_AHEAD_CHAR="↑" SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_COLOR=238 -SCM_THEME_PROMPT_CLEAN_COLOR=255 +SCM_THEME_PROMPT_CLEAN_COLOR=231 SCM_THEME_PROMPT_DIRTY_COLOR=220 CWD_THEME_PROMPT_COLOR=240 diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash index 815e92cc..a67463ae 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -16,7 +16,7 @@ SCM_GIT_AHEAD_CHAR="↑" SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_COLOR=238 -SCM_THEME_PROMPT_CLEAN_COLOR=255 +SCM_THEME_PROMPT_CLEAN_COLOR=231 SCM_THEME_PROMPT_DIRTY_COLOR=220 CWD_THEME_PROMPT_COLOR=240 From 24c1cd117060d54396046c17a1d98ca034e498a2 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Mon, 25 Nov 2013 17:07:14 -0600 Subject: [PATCH 28/46] Trim the whitespace from git stash output --- themes/base.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 96c7cf00..d616927d 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -90,7 +90,7 @@ function git_prompt_vars { local behind_re='.+behind ([0-9]+).+' [[ "${status}" =~ ${ahead_re} ]] && SCM_GIT_AHEAD=" ${SCM_GIT_AHEAD_CHAR}${BASH_REMATCH[1]}" [[ "${status}" =~ ${behind_re} ]] && SCM_GIT_BEHIND=" ${SCM_GIT_BEHIND_CHAR}${BASH_REMATCH[1]}" - local stash_count="$(git stash list | wc -l)" + local stash_count="$(git stash list | wc -l | tr -d ' ')" [[ "${stash_count}" -gt 0 ]] && SCM_GIT_STASH=" {${stash_count}}" } From 16704a68aaec5db526cc2215a9af1826f48ec35e Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Mon, 25 Nov 2013 18:02:58 -0600 Subject: [PATCH 29/46] Update to show the difference between staged, unstaged, and untracked files --- themes/powerline/powerline.theme.bash | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash index a67463ae..ab179aa4 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -17,7 +17,9 @@ SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_COLOR=238 SCM_THEME_PROMPT_CLEAN_COLOR=231 -SCM_THEME_PROMPT_DIRTY_COLOR=220 +SCM_THEME_PROMPT_DIRTY_COLOR=196 +SCM_THEME_PROMPT_STAGED_COLOR=220 +SCM_THEME_PROMPT_UNTRACKED_COLOR=033 CWD_THEME_PROMPT_COLOR=240 @@ -56,10 +58,18 @@ function powerline_virtualenv_prompt { function powerline_scm_prompt { scm_prompt_vars + local git_status_output + git_status_output=$(git status 2> /dev/null ) if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then if [[ "${SCM_DIRTY}" -eq 1 ]]; then - SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_DIRTY_COLOR} ${SCM_THEME_PROMPT_COLOR})" + if [ -n "$(echo $git_status_output | grep 'Changes not staged')" ]; then + SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_DIRTY_COLOR} ${SCM_THEME_PROMPT_COLOR})" + elif [ -n "$(echo $git_status_output | grep 'Changes to be committed')" ]; then + SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_STAGED_COLOR} ${SCM_THEME_PROMPT_COLOR})" + elif [ -n "$(echo $git_status_output | grep 'Untracked files')" ]; then + SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_UNTRACKED_COLOR} ${SCM_THEME_PROMPT_COLOR})" + fi else SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_CLEAN_COLOR} ${SCM_THEME_PROMPT_COLOR})" fi From 1a885b957f307fd1e38b0f2e29131942db07b083 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Mon, 25 Nov 2013 18:06:33 -0600 Subject: [PATCH 30/46] Add a fallback in case Git isn't being used (*shutters*) --- themes/powerline/powerline.theme.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash index ab179aa4..518f054c 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -69,6 +69,8 @@ function powerline_scm_prompt { SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_STAGED_COLOR} ${SCM_THEME_PROMPT_COLOR})" elif [ -n "$(echo $git_status_output | grep 'Untracked files')" ]; then SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_UNTRACKED_COLOR} ${SCM_THEME_PROMPT_COLOR})" + else + SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_DIRTY_COLOR} ${SCM_THEME_PROMPT_COLOR})" fi else SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_CLEAN_COLOR} ${SCM_THEME_PROMPT_COLOR})" From c398c9ee06f551005482170a93604e0580be0979 Mon Sep 17 00:00:00 2001 From: jimmynotjim Date: Tue, 26 Nov 2013 22:47:48 -0500 Subject: [PATCH 31/46] Added aliases for Vagrant --- aliases/available/vagrant.aliases.bash | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 aliases/available/vagrant.aliases.bash diff --git a/aliases/available/vagrant.aliases.bash b/aliases/available/vagrant.aliases.bash new file mode 100644 index 00000000..f8ff843f --- /dev/null +++ b/aliases/available/vagrant.aliases.bash @@ -0,0 +1,17 @@ +cite 'about-alias' +about-alias 'vagrant aliases' + +# Aliases +alias vup="vagrant up" +alias vh="vagrant halt" +alias vs="vagrant suspend" +alias vr="vagrant resume" +alias vrl="vagrant reload" +alias vssh="vagrant ssh" +alias vst="vagrant status" +alias vp="vagrant provision" +alias vdstr="vagrant destroy" +# requires vagrant-list plugin +alias vl="vagrant list" +# requires vagrant-hostmanager plugin +alias vhst="vagrant hostmanager" From 5d22da957b022180f5c3123d5ba962481d34a409 Mon Sep 17 00:00:00 2001 From: jimmynotjim Date: Wed, 27 Nov 2013 11:26:50 -0500 Subject: [PATCH 32/46] Added new aliases and plugins for git --- aliases/available/git.aliases.bash | 3 + plugins/available/git.plugin.bash | 94 ++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index ab868532..d0dacbd2 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -5,6 +5,8 @@ about-alias 'common git abbreviations' alias gcl='git clone' alias ga='git add' alias gall='git add .' +alias gus='git reset HEAD' +alias gm="git merge" alias g='git' alias get='git' alias gst='git status' @@ -19,6 +21,7 @@ alias gpo='git push origin' alias gdv='git diff -w "$@" | vim -R -' alias gc='git commit -v' alias gca='git commit -v -a' +alias gcm='git commit -v -m' alias gci='git commit --interactive' alias gb='git branch' alias gba='git branch -a' diff --git a/plugins/available/git.plugin.bash b/plugins/available/git.plugin.bash index 0b771111..533cc1d5 100644 --- a/plugins/available/git.plugin.bash +++ b/plugins/available/git.plugin.bash @@ -17,6 +17,100 @@ function git_first_push { git push origin master:refs/heads/master } +function git_pub() { + about 'publishes current branch to remote origin' + group 'git' + BRANCH=$(git rev-parse --abbrev-ref HEAD) + + echo "Publishing ${BRANCH} to remote origin" + git push -u origin $BRANCH +} + +function add_branch() { + about 'adds & tracks a remote branch' + group 'git' + + echo "Adding & tracking origin/${1}" + git checkout -b $1 origin/$1 +} + +function git_revert() { + about 'applies changes to HEAD that revert all changes after this commit' + group 'git' + + git reset $1 + git reset --soft HEAD@{1} + git commit -m "Revert to ${1}" + git reset --hard +} + +function git_rollback() { + about 'resets the current HEAD to this commit' + group 'git' + + function is_clean() { + if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]; then + echo "Your branch is dirty, please commit your changes" + kill -INT $$ + fi + } + + function commit_exists() { + git rev-list --quiet $1 + status=$? + if [ $status -ne 0 ]; then + echo "Commit ${1} does not exist" + kill -INT $$ + fi + } + + function keep_changes() { + while true + do + read -p "Do you want to keep all changes from rolled back revisions in your working tree? [Y/N]" RESP + case $RESP + in + [yY]) + echo "Rolling back to commit ${1} with unstaged changes" + git reset $1 + break + ;; + [nN]) + echo "Rolling back to commit ${1} with a clean working tree" + git reset --hard $1 + break + ;; + *) + echo "Please enter Y or N" + esac + done + } + + if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then + is_clean + commit_exists $1 + + while true + do + read -p "WARNING: This will change your history and move the current HEAD back to commit ${1}, continue? [Y/N]" RESP + case $RESP + in + [yY]) + keep_changes $1 + break + ;; + [nN]) + break + ;; + *) + echo "Please enter Y or N" + esac + done + else + echo "you're currently not in a git repository" + fi +} + function git_remove_missing_files() { about "git rm's missing files" group 'git' From 3aa33ea18a311b82dd2347bf1712b6e70012f2e1 Mon Sep 17 00:00:00 2001 From: jimmynotjim Date: Wed, 27 Nov 2013 13:07:47 -0500 Subject: [PATCH 33/46] Removed due to Git handling this automatically See this discussion https://github.com/revans/bash-it/pull/242/files#r7964126 --- plugins/available/git.plugin.bash | 8 -------- 1 file changed, 8 deletions(-) diff --git a/plugins/available/git.plugin.bash b/plugins/available/git.plugin.bash index 533cc1d5..6506ca45 100644 --- a/plugins/available/git.plugin.bash +++ b/plugins/available/git.plugin.bash @@ -26,14 +26,6 @@ function git_pub() { git push -u origin $BRANCH } -function add_branch() { - about 'adds & tracks a remote branch' - group 'git' - - echo "Adding & tracking origin/${1}" - git checkout -b $1 origin/$1 -} - function git_revert() { about 'applies changes to HEAD that revert all changes after this commit' group 'git' From faa8b9127162177464d0a28e4dfdb685f415c51a Mon Sep 17 00:00:00 2001 From: oddjobsman Date: Thu, 28 Nov 2013 00:07:29 +0530 Subject: [PATCH 34/46] Modified theme to use PROMPT_COMMAND instead of PS1 --- themes/sexy/sexy.theme.bash | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/themes/sexy/sexy.theme.bash b/themes/sexy/sexy.theme.bash index 949dcca4..15b9a972 100644 --- a/themes/sexy/sexy.theme.bash +++ b/themes/sexy/sexy.theme.bash @@ -40,4 +40,8 @@ parse_git_branch () { git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" } -PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]" +function prompt_command() { + PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]" +} + +PROMPT_COMMAND=prompt_command From 1a4f8140ffd95676b3c255db6be3f9d1824197cd Mon Sep 17 00:00:00 2001 From: Vaibhav Mishra Date: Thu, 28 Nov 2013 22:53:37 +0530 Subject: [PATCH 35/46] Fixed Alias for XCode under OSX --- aliases/available/osx.aliases.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aliases/available/osx.aliases.bash b/aliases/available/osx.aliases.bash index 3d82b500..3a5f45a1 100644 --- a/aliases/available/osx.aliases.bash +++ b/aliases/available/osx.aliases.bash @@ -5,7 +5,7 @@ about-alias 'osx-specific aliases' alias fireworks="open -a '/Applications/Adobe Fireworks CS3/Adobe Fireworks CS3.app'" alias photoshop="open -a '/Applications/Adobe Photoshop CS3/Adobe Photoshop.app'" alias preview="open -a '$PREVIEW'" -alias xcode="open -a '/Developer/Applications/Xcode.app'" +alias xcode="open -a '/Applications/XCode.app'" alias filemerge="open -a '/Developer/Applications/Utilities/FileMerge.app'" alias safari="open -a safari" alias firefox="open -a firefox" From d5bfb7fcb498e7ccf7927565a2e635b191f39734 Mon Sep 17 00:00:00 2001 From: jimmynotjim Date: Fri, 29 Nov 2013 14:19:26 -0500 Subject: [PATCH 36/46] Added plugin to create iso from current dir Includes options for custom name, dest dir and source dir --- plugins/available/base.plugin.bash | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/plugins/available/base.plugin.bash b/plugins/available/base.plugin.bash index e07401bc..b9cb7c49 100644 --- a/plugins/available/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -175,6 +175,30 @@ command_exists () type "$1" &> /dev/null ; } +mkiso () +{ + + about 'creates iso from current dir in the parent dir (unless defined)' + example 'mkdir' + example 'mkdir ISO-Name dest/path src/path' + group 'base' + + if type "mkisofs" > /dev/null; then + [ -z ${1+x} ] && local isoname=${PWD##*/} || local isoname=$1 + [ -z ${2+x} ] && local destpath=../ || local destpath=$2 + [ -z ${3+x} ] && local srcpath=${PWD} || local srcpath=$3 + + if [ ! -f "${destpath}${isoname}.iso" ]; then + echo "writing ${isoname}.iso to ${destpath} from ${srcpath}" + mkisofs -V ${isoname} -iso-level 3 -r -o "${destpath}${isoname}.iso" "${srcpath}" + else + echo "${destpath}${isoname}.iso already exists" + fi + else + echo "mkisofs cmd does not exist, please install cdrtools" + fi +} + # useful for administrators and configs buf () { From ff3c47ed432919123d68b370736c22bd6be5ef86 Mon Sep 17 00:00:00 2001 From: Timo Webler Date: Wed, 4 Dec 2013 13:42:58 +0100 Subject: [PATCH 37/46] Add bash completion support for Capistrano --- completion/available/capistrano.completion.bash | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 completion/available/capistrano.completion.bash diff --git a/completion/available/capistrano.completion.bash b/completion/available/capistrano.completion.bash new file mode 100644 index 00000000..a48bd4d6 --- /dev/null +++ b/completion/available/capistrano.completion.bash @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# Bash completion support for Capistrano. + +export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/} + +_capcomplete() { + if [ -f Capfile ]; then + recent=`ls -t .cap_tasks~ Capfile **/*.cap 2> /dev/null | head -n 1` + if [[ $recent != '.cap_tasks~' ]]; then + cap --tool --tasks | cut -d " " -f 2 > .cap_tasks~ + fi + COMPREPLY=($(compgen -W "`cat .cap_tasks~`" -- ${COMP_WORDS[COMP_CWORD]})) + return 0 + fi +} + +complete -o default -o nospace -F _capcomplete cap From 964850d6da50b2f776d28858a496581993224327 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Tue, 10 Dec 2013 16:59:22 +0100 Subject: [PATCH 38/46] Subtle change: Added a space in front of the command that's run in the new tab. If you use `export HISTIGNORE=' *'` in your shell, this will ensure that commands starting with a space will not be included in the history. Since the command sent to the new tab by the `tab` command probably shouldn't show up in the history, I added a leading space character. --- plugins/available/osx.plugin.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/available/osx.plugin.bash b/plugins/available/osx.plugin.bash index fde9c831..5b605ce2 100644 --- a/plugins/available/osx.plugin.bash +++ b/plugins/available/osx.plugin.bash @@ -11,7 +11,7 @@ function tab() { end tell application "Terminal" activate - do script with command "cd \"$PWD\"; $*" in window 1 + do script with command " cd \"$PWD\"; $*" in window 1 end tell EOF } From b65e0d0e40360fba7ae1dbcf90060447e2b3d4c3 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Fri, 13 Dec 2013 17:21:08 -0600 Subject: [PATCH 39/46] Add in Grunt auto-completion --- completion/available/grunt.completion.bash | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 completion/available/grunt.completion.bash diff --git a/completion/available/grunt.completion.bash b/completion/available/grunt.completion.bash new file mode 100644 index 00000000..99a96b5b --- /dev/null +++ b/completion/available/grunt.completion.bash @@ -0,0 +1,49 @@ +#!/bin/bash + +# grunt-cli +# http://gruntjs.com/ +# +# Copyright (c) 2012 Tyler Kellen, contributors +# Licensed under the MIT license. +# https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT + +# Usage: +# +# To enable bash completion for grunt, add the following line (minus the +# leading #, which is the bash comment character) to your ~/.bashrc file: +# +# eval "$(grunt --completion=bash)" + +# Search the current directory and all parent directories for a gruntfile. +function _grunt_gruntfile() { + local curpath="$PWD" + while [[ "$curpath" ]]; do + for gruntfile in "$curpath/"{G,g}runtfile.{js,coffee}; do + if [[ -e "$gruntfile" ]]; then + echo "$gruntfile" + return + fi + done + curpath="${curpath%/*}" + done + return 1 +} + +# Enable bash autocompletion. +function _grunt_completions() { + # The currently-being-completed word. + local cur="${COMP_WORDS[COMP_CWORD]}" + # The current gruntfile, if it exists. + local gruntfile="$(_grunt_gruntfile)" + # The current grunt version, available tasks, options, etc. + local gruntinfo="$(grunt --version --verbose 2>/dev/null)" + # Options and tasks. + local opts="$(echo "$gruntinfo" | awk '/Available options: / {$1=$2=""; print $0}')" + local compls="$(echo "$gruntinfo" | awk '/Available tasks: / {$1=$2=""; print $0}')" + # Only add -- or - options if the user has started typing - + [[ "$cur" == -* ]] && compls="$compls $opts" + # Tell complete what stuff to show. + COMPREPLY=($(compgen -W "$compls" -- "$cur")) +} + +complete -o default -F _grunt_completions grunt From c2c5f381c0b250905fce6bb44befb750ef06c989 Mon Sep 17 00:00:00 2001 From: Mariusz Fik Date: Mon, 16 Dec 2013 20:34:26 +0100 Subject: [PATCH 40/46] New simple theme, named 'pure'. Signed-off-by: Mariusz Fik --- themes/pure/pure.theme.bash | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 themes/pure/pure.theme.bash diff --git a/themes/pure/pure.theme.bash b/themes/pure/pure.theme.bash new file mode 100644 index 00000000..eaeb7655 --- /dev/null +++ b/themes/pure/pure.theme.bash @@ -0,0 +1,43 @@ +# scm theming +SCM_THEME_PROMPT_PREFIX="|" +SCM_THEME_PROMPT_SUFFIX="" + +SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}" +SCM_THEME_PROMPT_CLEAN=" ${green}✓${normal}" +SCM_GIT_CHAR="${green}±${normal}" +SCM_SVN_CHAR="${bold_cyan}⑆${normal}" +SCM_HG_CHAR="${bold_red}☿${normal}" + +### TODO: openSUSE has already colors enabled, check if those differs from stock +# 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:' + +scm_prompt() { + CHAR=$(scm_char) + if [ $CHAR = $SCM_NONE_CHAR ] + then + return + else + echo "[$(scm_char)$(scm_prompt_info)]" + fi +} + +pure_prompt() { + ps_host="${bold_blue}\h${normal}"; + ps_user="${green}\u${normal}"; + ps_user_mark="${green} $ ${normal}"; + ps_root="${red}\u${red}"; + ps_root="${red} # ${normal}" + ps_path="${yellow}\w${normal}"; + + # make it work + case $(id -u) in + 0) PS1="$ps_root@$ps_host$(scm_prompt):$ps_path$ps_root_mark" + ;; + *) PS1="$ps_user@$ps_host$(scm_prompt):$ps_path$ps_user_mark" + ;; + esac +} + +PROMPT_COMMAND=pure_prompt; From 55a37ad4c9fd477fb016fc41a8667fb61151c7d8 Mon Sep 17 00:00:00 2001 From: jimmynotjim Date: Thu, 19 Dec 2013 10:21:55 -0500 Subject: [PATCH 41/46] Fixed example arguments and added param arguments --- plugins/available/base.plugin.bash | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/available/base.plugin.bash b/plugins/available/base.plugin.bash index b9cb7c49..e028fe69 100644 --- a/plugins/available/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -179,8 +179,11 @@ mkiso () { about 'creates iso from current dir in the parent dir (unless defined)' - example 'mkdir' - example 'mkdir ISO-Name dest/path src/path' + param '1: ISO name' + param '2: dest/path' + param '3: src/path' + example 'mkiso' + example 'mkiso ISO-Name dest/path src/path' group 'base' if type "mkisofs" > /dev/null; then From 2c730cddee6ed0bd40b91e86a56d9fd31b8bb1b6 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Mon, 30 Dec 2013 17:51:48 -0500 Subject: [PATCH 42/46] Add Drush completion support --- completion/available/drush.completion.bash | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 completion/available/drush.completion.bash diff --git a/completion/available/drush.completion.bash b/completion/available/drush.completion.bash new file mode 100644 index 00000000..a65def6f --- /dev/null +++ b/completion/available/drush.completion.bash @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# +# bash completion support for Drush: +# https://github.com/drush-ops/drush +# +# Originally from: +# http://github.com/drush-ops/drush/blob/master/drush.complete.sh + +# Ensure drush is available. +which drush > /dev/null || alias drush &> /dev/null || return + +__drush_ps1() { + f="${TMPDIR:-/tmp/}/drush-env/drush-drupal-site-$$" + if [ -f $f ] + then + __DRUPAL_SITE=$(cat "$f") + else + __DRUPAL_SITE="$DRUPAL_SITE" + fi + + [[ -n "$__DRUPAL_SITE" ]] && printf "${1:- (%s)}" "$__DRUPAL_SITE" +} + +# Completion function, uses the "drush complete" command to retrieve +# completions for a specific command line COMP_WORDS. +_drush_completion() { + # Set IFS to newline (locally), since we only use newline separators, and + # need to retain spaces (or not) after completions. + local IFS=$'\n' + # The '< /dev/null' is a work around for a bug in php libedit stdin handling. + # Note that libedit in place of libreadline in some distributions. See: + # https://bugs.launchpad.net/ubuntu/+source/php5/+bug/322214 + COMPREPLY=( $(drush --early=includes/complete.inc "${COMP_WORDS[@]}" < /dev/null 2> /dev/null) ) +} + +# Register our completion function. We include common short aliases for Drush. +complete -o bashdefault -o default -o nospace -F _drush_completion d dr drush drush5 drush6 drush6 drush.php From 5ef3f817fef1aff10f34881f856a60f4066ac1ea Mon Sep 17 00:00:00 2001 From: aram price Date: Thu, 2 Jan 2014 11:27:14 -0800 Subject: [PATCH 43/46] Make chruby plugins conform to naming convention --- plugins/available/{chruby-auto.bash => chruby-auto.plugin.bash} | 0 plugins/available/{chruby.bash => chruby.plugin.bash} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename plugins/available/{chruby-auto.bash => chruby-auto.plugin.bash} (100%) rename plugins/available/{chruby.bash => chruby.plugin.bash} (100%) diff --git a/plugins/available/chruby-auto.bash b/plugins/available/chruby-auto.plugin.bash similarity index 100% rename from plugins/available/chruby-auto.bash rename to plugins/available/chruby-auto.plugin.bash diff --git a/plugins/available/chruby.bash b/plugins/available/chruby.plugin.bash similarity index 100% rename from plugins/available/chruby.bash rename to plugins/available/chruby.plugin.bash From 3b53623f6420c7615cf4cda7557e73c04f4daca1 Mon Sep 17 00:00:00 2001 From: John O'Gara Date: Sat, 4 Jan 2014 12:50:45 +0000 Subject: [PATCH 44/46] Added parsing of /etc/hosts and support for username@host completion --- completion/available/ssh.completion.bash | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/completion/available/ssh.completion.bash b/completion/available/ssh.completion.bash index 3dfd6ab7..fd5c6cd5 100644 --- a/completion/available/ssh.completion.bash +++ b/completion/available/ssh.completion.bash @@ -4,20 +4,33 @@ export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/} _sshcomplete() { + local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}" + if [[ ${CURRENT_PROMPT} == *@* ]] ; then + local OPTIONS="-P ${CURRENT_PROMPT/@*/}@ -- ${CURRENT_PROMPT/*@/}" + else + local OPTIONS=" -- ${CURRENT_PROMPT}" + fi + # parse all defined hosts from .ssh/config if [ -r $HOME/.ssh/config ]; then - COMPREPLY=($(compgen -W "$(grep ^Host $HOME/.ssh/config | awk '{print $2}' )" -- ${COMP_WORDS[COMP_CWORD]})) + COMPREPLY=($(compgen -W "$(grep ^Host $HOME/.ssh/config | awk '{print $2}' )" ${OPTIONS}) ) fi # parse all hosts found in .ssh/known_hosts if [ -r $HOME/.ssh/known_hosts ]; then if grep -v -q -e '^ ssh-rsa' $HOME/.ssh/known_hosts ; then - COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( awk '{print $1}' $HOME/.ssh/known_hosts | cut -d, -f 1 | sed -e 's/\[//g' | sed -e 's/\]//g' | cut -d: -f1 | grep -v ssh-rsa)" -- ${COMP_WORDS[COMP_CWORD]} )) + COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( awk '{print $1}' $HOME/.ssh/known_hosts | cut -d, -f 1 | sed -e 's/\[//g' | sed -e 's/\]//g' | cut -d: -f1 | grep -v ssh-rsa)" ${OPTIONS}) ) fi fi + + # parse hosts defined in /etc/hosts + if [ -r /etc/hosts ]; then + COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( grep -v '^[[:space:]]*$' /etc/hosts | grep -v '^#' | awk '{print $2}' )" ${OPTIONS}) ) + fi return 0 } complete -o default -o nospace -F _sshcomplete ssh + From adfd72a3ad592e3be11512b471ac3f273580ab19 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Thu, 9 Jan 2014 10:52:14 -0600 Subject: [PATCH 45/46] Fix so this works with the all themes (oops) --- plugins/available/virtualenv.plugin.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/available/virtualenv.plugin.bash b/plugins/available/virtualenv.plugin.bash index 93578395..651bfec7 100644 --- a/plugins/available/virtualenv.plugin.bash +++ b/plugins/available/virtualenv.plugin.bash @@ -19,14 +19,14 @@ function mkvbranch { about 'create a new virtualenv for the current branch' group 'virtualenv' - mkvirtualenv --distribute "$(basename `pwd`)@$(git_prompt_info)" + mkvirtualenv --distribute "$(basename `pwd`)@$SCM_BRANCH" } function wovbranch { about 'sets workon branch' group 'virtualenv' - workon "$(basename `pwd`)@$(git_prompt_info)" + workon "$(basename `pwd`)@$SCM_BRANCH" } function wovenv { From 2bc89fd8c1c1829ae3f97cf73ae307d84ecb76a6 Mon Sep 17 00:00:00 2001 From: Marshall Yount Date: Thu, 9 Jan 2014 12:37:06 -0600 Subject: [PATCH 46/46] add support for rbenv gemset command to bash prompt --- themes/base.theme.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index d616927d..9c5bedb3 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -132,6 +132,7 @@ function rvm_version_prompt { function rbenv_version_prompt { if which rbenv &> /dev/null; then rbenv=$(rbenv version-name) || return + $(rbenv commands | grep -q gemset) && gemset=$(rbenv gemset active) && rbenv="$rbenv@${gemset%% *}" echo -e "$RBENV_THEME_PROMPT_PREFIX$rbenv$RBENV_THEME_PROMPT_SUFFIX" fi }