From 41017622d413bd49fc497e0ffd3d570e0f81f9f6 Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Sun, 1 Oct 2023 16:20:36 -0400 Subject: [PATCH] add check for color prompt support --- .config/bash/.bashrc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.config/bash/.bashrc b/.config/bash/.bashrc index c14cc7c..0c655f7 100644 --- a/.config/bash/.bashrc +++ b/.config/bash/.bashrc @@ -110,9 +110,16 @@ git-prune() { git branch -vv | grep '\[origin/.*: gone\]' | awk '{print $1}' | xargs git branch -d } -# Set prompt -color_prompt=yes +# force_color_prompt=yes +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + color_prompt=yes + else + color_prompt= + fi +fi +# Set prompt if [ "$color_prompt" = yes ]; then PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]\$(parse_git_branch)\[\033[00m\] \$ " else