Skip to content

Instantly share code, notes, and snippets.

@avidit
Last active September 20, 2018 00:50
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 avidit/dfbe8aafdf2ced07cd2a4dcff9ba61a2 to your computer and use it in GitHub Desktop.
Save avidit/dfbe8aafdf2ced07cd2a4dcff9ba61a2 to your computer and use it in GitHub Desktop.
function bash_prompt {
# color
GREEN='\[\e[0;32m\]'
BLUE='\[\e[0;34m\]'
RESET='\[\e[0m\]'
# working dir
PROMPT="\W"
# git
if type "__git_ps1" > /dev/null 2>&1; then
PROMPT="$PROMPT$(__git_ps1 "${GREEN}(%s)${RESET}")"
fi
# virtualenv
if [[ $VIRTUAL_ENV != "" ]]; then
PROMPT="$PROMPT${BLUE}{${VIRTUAL_ENV##*/}}${RESET}"
fi
PS1="$PROMPT\$ "
}
export -f bash_prompt
# Bash shell executes this function just before displaying the PS1 variable
export PROMPT_COMMAND='bash_prompt'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment