Skip to content

Instantly share code, notes, and snippets.

@pearkes
Created November 13, 2012 23:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pearkes/4069203 to your computer and use it in GitHub Desktop.
Save pearkes/4069203 to your computer and use it in GitHub Desktop.
My shell prompt, with Vagrant and Git status.
# Example: http://s.jack.ly/iXhJ
prompt() {
PS1="${GREEN}\W\$(parse_git_branch) $BROWN\$(parse_vm_state) ${GREEN}→ ${GREY}"
PS2="\[[33;1m\]continue \[[0m[1m\]> "
}
parse_git_branch() {
[ -d .git ] || return 1
/usr/local/bin/git symbolic-ref HEAD 2> /dev/null | sed 's#\(.*\)\/\([^\/]*\)$# \2#'
}
parse_vm_state() {
# Check to see if we're in a directory with vagrant
[ -e .vagrant ] || return 1
VBoxManage showvminfo $(cat .vagrant | sed 's/.*\"\(.*\)\"[^\"]*$/\1/') --machinereadable | grep 'VMState=' | sed 's/.*"\(.*\)"[^"]*$/\1/'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment