Skip to content

Instantly share code, notes, and snippets.

@AyresMonteiro
Last active October 2, 2024 18:45
Show Gist options
  • Save AyresMonteiro/c2a048e9ff051069b745f66ae1aecbfa to your computer and use it in GitHub Desktop.
Save AyresMonteiro/c2a048e9ff051069b745f66ae1aecbfa to your computer and use it in GitHub Desktop.
[Debian] Add it to ~/.bashrc and show current git branch on bash
# You need to acquire a copy of that script from git source code
# then place it in your home dir
source ~/git-prompt.sh
# Function to safely wrap __git_ps1 for use in PS1
git_branch_prompt() {
local branch
branch="$(__git_ps1 ' (%s)')"
if [ -n "$branch" ]; then
echo "\[\033[1;33m\]$branch\[\033[0m\]"
else
echo ""
fi
}
COMPLETE_CURRENT_DATE="\D{%F %T}"
CURRENT_DATE="\D{%T}"
YELLOW="\e[33m"
BOLD="\e[1m"
BOLD_YELLOW="\e[1;33m"
BOLD_RED="\e[1;91m"
COLOR_END="\e[0m"
COLORED_DATE="${BOLD_YELLOW}[${CURRENT_DATE}]${COLOR_END}"
COLORED_USER="\[\033[01;32m\]\u\[\033[00m\]"
COLORED_PATH="\[\033[01;34m\]\w\[\033[00m\]"
COLORED_DIR="\[\033[01;34m\]\W\[\033[00m\]"
COLORED_GIT_BRANCH="${BOLD_YELLOW}\$(git_branch_prompt)${COLOR_END}"
COLORED_INDICATOR="\[\033[1m\]/>\[\033[0m\]"
BASE_PS1="\[\e]0;Ayres' Terminal - \u@\h \W\a\]${debian_chroot:+($debian_chroot)}"
# Set PROMPT_COMMAND to update the PS1 before each prompt
PROMPT_COMMAND='PS1="${BASE_PS1}${COLORED_USER} ${COLORED_DIR}$(git_branch_prompt) ${COLORED_INDICATOR} "'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment