Skip to content

Instantly share code, notes, and snippets.

@arthurattwell
Last active December 5, 2019 16:14
Show Gist options
  • Save arthurattwell/8893daea830cb6dd9073223bed932a93 to your computer and use it in GitHub Desktop.
Save arthurattwell/8893daea830cb6dd9073223bed932a93 to your computer and use it in GitHub Desktop.
Set the Terminal prompt in Ubuntu
# Set the Terminal prompt in Ubuntu to:
# user directory (git-branch) $
# Add the lines below to your ~/.bashrc file.
## Get Git branch
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
## Simplify prompt and add Git branch
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\] \w\[\033[01;34m\]\[\033[00m\]\[\033[01;36m\]$(parse_git_branch)\[\033[00m\] \$ '
## Set title as directory
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\w\a\]$PS1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment