Skip to content

Instantly share code, notes, and snippets.

@saneef
Last active December 22, 2015 01:38
Show Gist options
  • Save saneef/6397406 to your computer and use it in GitHub Desktop.
Save saneef/6397406 to your computer and use it in GitHub Desktop.
# Bash Profile * Display Current Git branch together with current full path on Bash prompt * Autocomplete commands after ‘sudo’
## Git branch and current full path in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# Use \W instead of \w to show only current directory
export PS1="\u@\h: \w\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
## Autocomplete after ‘sudo’
if [ "$PS1" ]; then
complete -cf sudo
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment