From b149449ff3f96d26a8e8979f93b1fdba6bd4371c Mon Sep 17 00:00:00 2001 From: Andrew Stowell Date: Wed, 19 Oct 2022 14:48:36 -0400 Subject: [PATCH] basic settings can now add git-prompt. --- one-time-stuff/basic-settings.sh | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/one-time-stuff/basic-settings.sh b/one-time-stuff/basic-settings.sh index e539d7e..6f71599 100755 --- a/one-time-stuff/basic-settings.sh +++ b/one-time-stuff/basic-settings.sh @@ -146,6 +146,29 @@ esac # ---------------------------------------------------------- +echo "----- Download Git Prompt Script --------------------" +read -p 'Add git prompt to bash config? [y/N]: ' set_prompt +case $set_prompt in + [Yy]* ) + echo 'Downloading Git Prompt' + LOCATION=`dirname "$0"` + [ ! -d "${HOME}/bin" ] && mkdir "${HOME}/bin" + wget 'https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh' -O "${HOME}/bin/git-prompt.sh" -q && ( cat << 'PROMPT' + +# ABS git prompt +source ~/bin/git-prompt.sh + +PROMPT +) >> "${HOME}/.bashrc" + chmod +x "${HOME}/bin/git-prompt.sh" + ;; + * ) + echo 'Skipping' + ;; +esac + +# ---------------------------------------------------------- + echo "----- Append prompt style to ~/.bashrc --------------" read -p 'Add prompt style to bash config? [y/N]: ' add_style case $add_style in @@ -155,7 +178,11 @@ case $add_style in cat << 'STYLE' # ABS prompt color -PS1="\[\e[32m\]\u\[\e[m\]@\[\e[36m\]\h\[\e[m\]:\[\e[33m\]\w\[\e[m\]\\$ " +if [ "$(type -t __git_ps1)" == 'function' ]; then + PS1='\[\e[32m\]\u\[\e[m\]@\[\e[36m\]\h\[\e[m\]:\[\e[33m\]\w\[\e[m\]$(__git_ps1 "\e[m\](\e[35m\]%s\e[m\])")\e[m\]\\$ ' +else + PS1="\[\e[32m\]\u\[\e[m\]@\[\e[36m\]\h\[\e[m\]:\[\e[33m\]\w\[\e[m\]\\$ " +fi STYLE ) >> "$HOME/.bashrc"