Skip to content

Instantly share code, notes, and snippets.

@dezashibi
Last active July 30, 2024 08:33
Show Gist options
  • Save dezashibi/83814a9830a2b03015d7f9c1428bf4fe to your computer and use it in GitHub Desktop.
Save dezashibi/83814a9830a2b03015d7f9c1428bf4fe to your computer and use it in GitHub Desktop.
Quick and small snippet to customize bash prompt
# the addition is the `parse_git_branch` function, the colorizing and the order of shown data
parse_git_branch() {
git branch 2>/dev/null | grep '*' | sed 's/* //'
}
# refer to the structure of your bashrc and change it accordingly
if [ "$color_prompt" = yes ]; then
PS1='\[\033[00m\]┌\[\033[01;36m\]\t \[\033[01;34m\]\w\[\033[00m\]\n${debian_chroot:+($debian_chroot)}└\[\033[01;32m\]\u (\[\033[01;33m\]$(parse_git_branch)\[\033[01;32m\])\$ \[\033[00m\]'
else
PS1='┌\t \w\n${debian_chroot:+($debian_chroot)}└\u ($(parse_git_branch))\$ '
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment