aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/prompt.bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2015-03-25 19:23:00 +1300
committerTom Ryder <tom@sanctum.geek.nz>2015-03-25 19:23:00 +1300
commit8f6f397538c1b346607ab88d6499d24765efebd7 (patch)
tree28999a31d1c17b19df8e392ac6b390f691f5351e /bash/bashrc.d/prompt.bash
parentImproved syntax for the Vim plugin targets (diff)
downloaddotfiles-8f6f397538c1b346607ab88d6499d24765efebd7.tar.gz
dotfiles-8f6f397538c1b346607ab88d6499d24765efebd7.zip
Change if-elseif chain to a switch-case
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"'\] '