Skip to content

Instantly share code, notes, and snippets.

@s-nt-s
Created April 25, 2022 10:09
Show Gist options
  • Save s-nt-s/3d0908ae7034da90c9c79d15bc48a6fe to your computer and use it in GitHub Desktop.
Save s-nt-s/3d0908ae7034da90c9c79d15bc48a6fe to your computer and use it in GitHub Desktop.
prompt
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w \$\[\033[00m\] '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h \w\$ '
fi
parse_git_branch() {
if git rev-parse --is-inside-work-tree --quiet &> /dev/null; then
GIT_BRANCH="$(git branch | grep "^*" | colrm 1 2)"
if [[ $(git status -s 2> /dev/null) ]]; then
echo -e "\033[0;31m($GIT_BRANCH) "
else
echo -e "\033[0;32m($GIT_BRANCH) "
fi
fi
}
PS1="\$(parse_git_branch)${PS1}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment