Skip to content

Instantly share code, notes, and snippets.

@marianocordoba
Last active May 13, 2021 15:58
Show Gist options
  • Save marianocordoba/df0adb3e5d0fbd12c568028e5823353f to your computer and use it in GitHub Desktop.
Save marianocordoba/df0adb3e5d0fbd12c568028e5823353f to your computer and use it in GitHub Desktop.
Cool bash prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
show_git_branch() {
if [ ! -z "$(parse_git_branch)" ]; then
echo -e "\001\033[48;5;8;38;5;4m\002\ue0b0\001\033[0m\002\001\033[0;48;5;8m\002 \uf418 $(parse_git_branch) \001\033[0m\002\001\033[0;38;5;8m\002\ue0b0\001\033[0m\002 "
else
echo -e "\001\033[38;5;4m\002\ue0b0\001\033[0m\002 "
fi
}
PS1='\[\033[0;48;5;4m\] \w \[\033[0m\]$(show_git_branch)'
@UnnatShaneshwar
Copy link

UnnatShaneshwar commented May 13, 2021

awesome thanks

this PS1 is so confusing without variables I recommend making variable

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