aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/prompt.bash
diff options
context:
space:
mode:
Diffstat (limited to 'bash/bashrc.d/prompt.bash')
-rw-r--r--bash/bashrc.d/prompt.bash47
1 files changed, 27 insertions, 20 deletions
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash
index 9aae086d..128717d8 100644
--- a/bash/bashrc.d/prompt.bash
+++ b/bash/bashrc.d/prompt.bash
@@ -30,26 +30,33 @@ prompt() {
} 2>/dev/null )
local format
- # Check if we have non-bold bright green available
- if ((colors == 256)) ; then
- format=$( {
- tput AF 10 || tput setaf 10 \
- || tput AF 10 0 0 || tput setaf 10 0 0
- } 2>/dev/null )
-
- # If we have only eight colors, use bold green to make it bright
- elif ((colors == 8)) ; then
- format=$( {
- tput AF 2 || tput setaf 2
- tput md || tput bold
- } 2>/dev/null )
-
- # For non-color terminals (!), just use bold
- else
- format=$( {
- tput md || tput bold
- } 2>/dev/null )
- fi
+ # Decide prompt color formatting based on color availability
+ case $colors in
+
+ # Check if we have non-bold bright green available
+ 256)
+ format=$( {
+ tput AF 10 || tput setaf 10 \
+ || tput AF 10 0 0 || tput setaf 10 0 0
+ } 2>/dev/null )
+ ;;
+
+ # If we have only eight colors, use bold green
+ 8)
+ format=$( {
+ tput AF 2 || tput setaf 2
+ tput md || tput bold
+ } 2>/dev/null )
+ ;;
+
+ # For all other terminals, we assume non-color (!), and we just
+ # use bold
+ *)
+ format=$( {
+ tput md || tput bold
+ } 2>/dev/null )
+ ;;
+ esac
# String it all together
PS1='\['"$format"'\]'"$PS1"'\['"$reset"'\] '