commit e29a567ffd25de6a98bde9d5e4402d3e6de46008 (patch) parent c306dd12b0371077cc18baf9dd820e78208e2cc2 Author: Alex Karle <alex@karle.co> Date: Thu, 28 May 2020 22:28:15 -0400 bash: Disable fancy prompt by default I've been using a stripped down prompt on most of my machines these days. On the machines I want to see more, I'll opt in with a USE_FANCY_PROMPT=1 in ~/.bashrc.local (which is sourced before this). Diffstat:
M | bash/bashrc | | | 50 | ++++++++++++++++++++++++++------------------------ |
1 file changed, 26 insertions(+), 24 deletions(-)
diff --git a/bash/bashrc b/bash/bashrc @@ -22,31 +22,33 @@ include "$HOME/.bash/git-completion.bash" # Git Completion include "$HOME/.console_theme" # Virtual Console colors (if TERM == "linux") include "$HOME/.bashrc.local" # System specific settings -parse_git_dirty() { - if [ -z "$BASH_PROMPT_NO_GSTATUS" ]; then - [ "$(git status --porcelain=v1 2> /dev/null)" ] && echo "*" +if [ -n "$USE_FANCY_PROMPT" ]; then + parse_git_dirty() { + if [ -z "$BASH_PROMPT_NO_GSTATUS" ]; then + [ "$(git status --porcelain=v1 2> /dev/null)" ] && echo "*" + fi + } + + git_info() { + git branch --no-color 2> /dev/null | + sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" + } + + # Preferred Prompt: fancy with colors from tput + if tput setaf 1 &> /dev/null; then + tput sgr0 # reset effects of test command + RED="\[$(tput setaf 1)\]" + MAGENTA="\[$(tput setaf 5)\]" + YELLOW="\[$(tput setaf 3)\]" + GRAY="\[$(tput setaf 8)\]" + BLUE="\[$(tput setaf 4)\]" + BOLD="\[$(tput bold)\]" + RESET="\[$(tput sgr0)\]" + + PS1_TOP="$BOLD$RED\$(last_err)$BLUE\w $RESET$GRAY$SSH_PROMPT\$(git_info)" + PS1="$PS1_TOP\n$BOLD$MAGENTA\$ $RESET" + PS2="$YELLOW> $RESET" fi -} - -git_info() { - git branch --no-color 2> /dev/null | - sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" -} - -# Preferred Prompt: fancy with colors from tput -if tput setaf 1 &> /dev/null; then - tput sgr0 # reset effects of test command - RED="\[$(tput setaf 1)\]" - MAGENTA="\[$(tput setaf 5)\]" - YELLOW="\[$(tput setaf 3)\]" - GRAY="\[$(tput setaf 8)\]" - BLUE="\[$(tput setaf 4)\]" - BOLD="\[$(tput bold)\]" - RESET="\[$(tput sgr0)\]" - - PS1_TOP="$BOLD$RED\$(last_err)$BLUE\w $RESET$GRAY$SSH_PROMPT\$(git_info)" - PS1="$PS1_TOP\n$BOLD$MAGENTA\$ $RESET" - PS2="$YELLOW> $RESET" fi # Git completion for ~/.aliases