Skip to content

Instantly share code, notes, and snippets.

@kemayo
Created April 19, 2014 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kemayo/11100293 to your computer and use it in GitHub Desktop.
Save kemayo/11100293 to your computer and use it in GitHub Desktop.
source ~/.profile
# employing this prompt: http://vvv.tobiassjosten.net/bash/dynamic-prompt-with-git-and-ansi-colors
# Configure colors, if available.
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
c_reset='\[\e[0m\]'
c_user='\[\033[1;33m\]'
c_path='\[\e[0;33m\]'
c_git_clean='\[\e[0;36m\]'
c_git_dirty='\[\e[0;35m\]'
else
c_reset=
c_user=
c_path=
c_git_clean=
c_git_dirty=
fi
# Function to assemble the Git part of our prompt.
git_prompt ()
{
if ! git rev-parse --git-dir > /dev/null 2>&1; then
return 0
fi
git_branch=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
if git diff --quiet 2>/dev/null >&2; then
git_color="$c_git_clean"
else
git_color="$c_git_dirty"
fi
echo " [$git_color$git_branch${c_reset}]"
}
add_venv_info () {
if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then
_OLD_VIRTUAL_PS1="$PS1"
if [ "x" != x ] ; then
PS1="$PS1"
else
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
elif [ "$VIRTUAL_ENV" != "" ]; then
PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
fi
fi
export PS1
fi
}
# Thy holy prompt.
PROMPT_COMMAND='PS1="${c_user}\u${c_reset}@${c_user}\h${c_reset}:${c_path}\w${c_reset}$(git_prompt)\$ " add_venv_info'
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment