aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/prompt.bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2013-09-04 17:49:36 +1200
committerTom Ryder <tom@sanctum.geek.nz>2013-09-04 17:49:36 +1200
commitcd6f01749d707aafc7a6aebb7170e4fab37766ff (patch)
tree49e9b24347a25fa4b73c2c342a22eb2b0b771b61 /bash/bashrc.d/prompt.bash
parentCorrect array appending syntax in README (diff)
downloaddotfiles-cd6f01749d707aafc7a6aebb7170e4fab37766ff.tar.gz
dotfiles-cd6f01749d707aafc7a6aebb7170e4fab37766ff.zip
Better graceful degradation for prompt formatting
OpenBSD hates me
Diffstat (limited to 'bash/bashrc.d/prompt.bash')
-rw-r--r--bash/bashrc.d/prompt.bash20
1 files changed, 12 insertions, 8 deletions
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash
index 22258022..5b3e0126 100644
--- a/bash/bashrc.d/prompt.bash
+++ b/bash/bashrc.d/prompt.bash
@@ -10,22 +10,26 @@ prompt() {
PROMPT_COMMAND='ret=$? ; history -a'
PS1='\[\a\][\u@\h:\w]$(prompt vcs)$(prompt job)$(prompt ret)\$'
- # Count available colors
+ # Count available colors, reset, and format (decided shortly)
local colors=$(tput colors)
+ local reset=$(tput sgr0)
+ local format
# Check if we have non-bold bright green available
- local color
if ((colors > 8)); then
- color=$(tput setaf 10)
+ format=$(tput setaf 10 0 0)
+
+ # If we have only eight colors, use bold green to make it bright
+ elif ((colors == 8)); then
+ format=$(tput setaf 2)$(tput bold)
+
+ # For non-color terminals (!), just use bold
else
- color=$(tput setaf 2)$(tput bold)
+ format=$(tput bold)
fi
- # Reset color and attributes
- local reset=$(tput sgr0)
-
# String it all together
- PS1='\['"$color"'\]'"$PS1"'\['"$reset"'\] '
+ PS1='\['"$format"'\]'"$PS1"'\['"$reset"'\] '
;;
# Revert to simple inexpensive prompt