Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
My Mac Terminal bash prompt.
# Set the prompt
# This will show something like:
#
# chris@chris-ubuntu in ~
# ›
PS1='\n\[\033[01;35m\]\u@\h\[\033[00m\] in \[\033[01;34m\]\w\[\033[00m\]\n› '
case "$TERM" in
xterm*|rxvt*)
PROMPT_COMMAND='set_tab_title'
;;
*)
;;
esac
# set tab name to basename or git repo (branch) if in git dir
function set_tab_title() {
GIT_PS1_SHOWDIRTYSTATE=true
local GIT_PS1=$(__git_ps1)
if [ "$GIT_PS1" ]; then
printf "\e]1;$(greadlink -m $(__gitdir)/../ | xargs basename)$GIT_PS1\a"
else
printf "\e]1;$(basename $(pwd))\a"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment