Created
June 15, 2020 22:09
-
-
Save mrsarm/9675dc4b3219dbc862f2bd16067f23ad to your computer and use it in GitHub Desktop.
bash_prompt_custom.sh Bash prompt config (add to your ~/.bashrc)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then | |
c_reset='\e[0m' | |
c_git_clean='\e[0;32m' | |
c_git_dirty='\e[0;31m' | |
else | |
c_reset= | |
c_git_clean= | |
c_git_dirty= | |
fi | |
git_prompt () | |
{ | |
if ! git rev-parse --git-dir > /dev/null 2>&1; then | |
return 0 | |
fi | |
git_branch=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p') | |
if git diff --quiet 2>/dev/null >&2; then | |
git_color="${c_git_clean}" | |
else | |
git_color=${c_git_dirty} | |
fi | |
echo -e " [$git_color$git_branch${c_reset}] " | |
} | |
# This version of $PS1 is the same Ubuntu 20.04 has by default, with the addtion of the git info, | |
# you can setup instead $PROMPT_COMMAND like https://raw.githubusercontent.com/mr-sudaca/dotfiles/master/files/prompt | |
PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\e[0m\]$(git_prompt)\$ ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment