Skip to content

Instantly share code, notes, and snippets.

@mrlannigan
Last active December 30, 2015 22:29
Show Gist options
  • Save mrlannigan/7894179 to your computer and use it in GitHub Desktop.
Save mrlannigan/7894179 to your computer and use it in GitHub Desktop.
Bash Prompt
#!/bin/bash
[ -z "$PS1" ] && return
PROMPT_COMMAND='RET=$?;'
if [ ! -f ~/.git-completion.sh ]; then
curl -s https://raw.github.com/git/git/master/contrib/completion/git-completion.bash > ~/.git-completion.sh && chmod +x .git-completion.sh
fi
if [ ! -f ~/.git-prompt.sh ]; then
curl -s https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh > ~/.git-prompt.sh && chmod +x .git-prompt.sh
fi
if [ -f ~/.git-completion.sh ]; then
. ~/.git-completion.sh
fi
if [ -f ~/.git-prompt.sh ]; then
. ~/.git-prompt.sh
fi
function _returnLambda {
if [[ $RET = 0 ]]; then echo -e '\033[01;32m'; else echo -e '\033[01;31m'; fi;
}
function __svn_branch {
if [ -d .svn ]; then
_branchName=`svn info | grep '^URL:' | egrep -o '(tags|branches)/[^/]+|trunk' | egrep -o '[^/]+$'`
if [ -n $_branchName ]; then
echo -ne `printf $1 ' ' $_branchName`
fi
fi
}
PS1='\[\033[01;32m\] \[$(_returnLambda)\]λ \[\033[01;34m\]\W$(__svn_branch "\[\e[32m\]%s[%s]")$(__git_ps1 \ \[\e[32m\][%s]) \[\e[1;37m\]\$\[\033[00m\] '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment