Skip to content

Instantly share code, notes, and snippets.

@Calmarius
Created January 21, 2022 20:07
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 Calmarius/27ab09c80c55956090b064220122af40 to your computer and use it in GitHub Desktop.
Save Calmarius/27ab09c80c55956090b064220122af40 to your computer and use it in GitHub Desktop.
PROMPT_COLOR=${PROMPT_COLOR:-'\[\033[01;38;5;56m\]'}
VIRTUAL_ENV_DISABLE_PROMPT=1
function prompt_command()
{
local EXIT=$?
# Color codes
local PROMPT_COLOR=${PROMPT_COLOR:-'\[\033[01;35m\]'}
local RESET_COLOR='\[\033[00m\]'
# Exit code string
local EXIT_PROMPT="EC: $EXIT"
# Show git branch
local GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
local GIT_PROMPT=''
if [ ! -z $GIT_BRANCH ]
then
GIT_PROMPT=" | GIT: $GIT_BRANCH"
fi
# Check if in Python
local PYTHON_VENV=''
if [ ! -z $VIRTUAL_ENV ]
then
PYTHON_VENV=" | PY: $(basename $VIRTUAL_ENV)"
fi
export PS1=$PROMPT_COLOR'--------------------\n\u@\H\n'"${EXIT_PROMPT}${PYTHON_VENV}${GIT_PROMPT}"$'\n''\w\n$ '$RESET_COLOR
}
PROMPT_COMMAND=prompt_command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment