Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rodrigondec/f26d0fe3a364af107fc231dc56456d96 to your computer and use it in GitHub Desktop.
Save rodrigondec/f26d0fe3a364af107fc231dc56456d96 to your computer and use it in GitHub Desktop.
bash PS1 ao meu gosto
# https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash/13864829#13864829
# https://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
# https://stackoverflow.com/a/5947802
# https://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/
git_branch() {
branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
BEGIN_CYAN='\033[0;36m'
END_CYAN='\033[0m'
if [ -z "$branch" ]
then
echo ""
else
echo -e " ${BEGIN_CYAN}{$branch}${END_CYAN} "
fi
}
export PS1="\[\e]0;\u: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$(git_branch)\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment