Skip to content

Instantly share code, notes, and snippets.

@greenygh0st
Last active July 16, 2020 16:05
Show Gist options
  • Save greenygh0st/472fe59e45c5575efbb88e8de1546d0e to your computer and use it in GitHub Desktop.
Save greenygh0st/472fe59e45c5575efbb88e8de1546d0e to your computer and use it in GitHub Desktop.

Git branch in prompt.

parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* (.*)/ [\1]/' }

export PS1="\u@\h \W[\033[01;33m]$(parse_git_branch)[\033[00m] $ "

Here are some other terminal colour codes you can use:

Some other cool options: Regular colours: [\033[00;30m] – Black [\033[00;31m] – Red [\033[00;32m] – Green [\033[00;33m] – Yellow [\033[00;34m] – Blue [\033[00;35m] – Purple [\033[00;36m] – Cyan [\033[00;37m] – White

High intensity: [\033[00;90m] – Black [\033[00;91m] – Red [\033[00;92m] – Green [\033[00;93m] – Yellow [\033[00;94m] – Blue [\033[00;95m] – Purple [\033[00;96m] – Cyan [\033[00;97m] – White

Background: [\033[40m] – Black [\033[41m] – Red [\033[42m] – Green [\033[43m] – Yellow [\033[44m] – Blue [\033[45m] – Purple [\033[46m] – Cyan [\033[47m] – White

Backgrounds with high intensity: [\033[00;100m] – Black [\033[00;101m] – Red [\033[00;102m] – Green [\033[00;103m] – Yellow [\033[00;104m] – Blue [\033[10;95m] – Purple [\033[00;106m] – Cyan [\033[00;107m] – White

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