Skip to content

Instantly share code, notes, and snippets.

@kenvac
Created May 9, 2023 08:59
Show Gist options
  • Save kenvac/fbe97e814608711e231bbd861f28ec84 to your computer and use it in GitHub Desktop.
Save kenvac/fbe97e814608711e231bbd861f28ec84 to your computer and use it in GitHub Desktop.
macOS virtualenv and git branch
# Scripts
parse_git_branch() {
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
COLOR_DEF='%f'
COLOR_USR='%F{243}'
COLOR_DIR='%F{197}'
COLOR_GIT='%F{39}'
NEWLINE=$'\n'
setopt PROMPT_SUBST
export PROMPT='${COLOR_USR}%n@%M ${COLOR_DIR}%d ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF}${NEWLINE}%% '
setopt PROMPT_SUBST
show_virtual_env() {
if [[ -n "$VIRTUAL_ENV" && -n "$DIRENV_DIR" ]]; then
echo "($(basename $VIRTUAL_ENV))"
fi
}
PS1='$(show_virtual_env)'$PS1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment