Skip to content

Instantly share code, notes, and snippets.

@benspaulding
Last active December 12, 2015 12:19
Show Gist options
  • Save benspaulding/4771655 to your computer and use it in GitHub Desktop.
Save benspaulding/4771655 to your computer and use it in GitHub Desktop.
My vcprompt setup.
# First, install vcprompt.
brew update
brew tap homebrew/headonly
brew install --HEAD vcprompt
# Part of .bashrc
# Set up a custom prompt.
# First, some color definitions.
BLUE="\[\033[0;34m\]"
BROWN="\[\033[0;33m\]"
CYAN="\[\033[0;36m\]"
GREEN="\[\033[0;32m\]"
RED="\[\033[0;31m\]"
NO_COLOR="\[\e[0m\]"
# The virtualenv part of the prompt.
function ve_prompt() {
if [ -n "${VIRTUAL_ENV+x}" ]; then
echo "(`basename \"$VIRTUAL_ENV\"`) "
else
echo ""
fi
}
# The version control part of the prompt.
function vc_prompt() {
if test $? -eq 0; then
local PROMPT_COLOR=$CYAN
else
local PROMPT_COLOR=$RED
fi
# This doesn't work. :( Need to figure out why. For now we hardcode colors (below).
# echo "${RED}\h ${BLUE}\w ${BROWN}$(vcprompt) ${GREEN}$(ve_prompt) ${RED}$($HOME/.rvm/bin/rvm-prompt v p g -d) ${CYAN}\t\n${PROMPT_COLOR}\$${NO_COLOR}"
echo '\[\033[0;31m\]\h \[\033[0;34m\]\w \[\033[0;33m\]$(vcprompt)\[\033[0;32m\]$(ve_prompt)\[\033[0;31m\]$($HOME/.rvm/bin/rvm-prompt v p g -d) \[\033[0;36m\]\t\n\[\033[0;36m\]\$\[\e[0m\]'
}
PS1="$(vc_prompt) "
PS2="${CYAN}…${NO_COLOR} "
# Resulting prompt is something like this. The version control, virtual env, and ruby (rvm) info are all
# conditional on said thing being activated/in-use. I like my prompt to be on a new line so commands I
# run are easy to scan, and I like the time so I can easily see how long something took to run, or how
# long I was out to lunch.
Host ~/mah/path [vcs:branch] (venv_name) ruby@gemset 10:29:57
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment