Skip to content

Instantly share code, notes, and snippets.

@angel-vladov
Last active August 29, 2018 10:05
Show Gist options
  • Save angel-vladov/753a1f57b4dd8a6573676d8ba8980104 to your computer and use it in GitHub Desktop.
Save angel-vladov/753a1f57b4dd8a6573676d8ba8980104 to your computer and use it in GitHub Desktop.
Mac OS terminal prompt with git branch
export PATH="/usr/local/bin:$PATH"
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
PS1='\[\033[32m\]' # change to green
PS1="$PS1"'\u@\h ' # user@host<space>
PS1="$PS1"'\[\033[33m\]' # change to brownish yellow
PS1="$PS1"'\w' # current working directory
PS1="$PS1"'\[\033[36m\]' # change color to cyan
PS1="$PS1"'$(parse_git_branch 2>/dev/null)' # change color to cyan
PS1="$PS1"'\[\033[0m\]' # change color
PS1="$PS1"'\n' # new line
export PS1="$PS1"'$ ' # prompt: always $
@angel-vladov
Copy link
Author

angel-vladov commented Jul 28, 2018

Usage:

  • Place in your user folder and from there run source .bash_profile.

Preview (with SMYCK color theme):
Mac Terminal using SMYCK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment