diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2013-09-22 15:02:16 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2013-09-22 15:02:16 +1200 |
commit | 8ff706eb776a5a7549045d09c8331361d280d8fa (patch) | |
tree | 73a973193ad9a8116a3c538f347fd1791c694f32 /bash | |
parent | Correct var definitions for read (diff) | |
download | dotfiles-8ff706eb776a5a7549045d09c8331361d280d8fa.tar.gz dotfiles-8ff706eb776a5a7549045d09c8331361d280d8fa.zip |
Attempt at terminal independence of prompt color
If it gets much more involved than this I'll probably just not bother
with termcap, I don't very often use BSD systems but it would be nice if
it Just Worked
Diffstat (limited to 'bash')
-rw-r--r-- | bash/bashrc.d/prompt.bash | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash index 00f6538e..96ad6546 100644 --- a/bash/bashrc.d/prompt.bash +++ b/bash/bashrc.d/prompt.bash @@ -16,21 +16,33 @@ prompt() { fi # Count available colors, reset, and format (decided shortly) - local colors=$(tput colors) - local reset=$(tput sgr0) + local colors=$( { + tput Co || tput colors + } 2>/dev/null ); + local reset=$( { + tput me || tput sgr0 + } 2>/dev/null ); local format # Check if we have non-bold bright green available if ((colors == 256)); then - format=$(tput setaf 10) + format=$( { + tput AF 10 || tput setaf 10 \ + || tput AF 10 0 0 || tput AF 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 setaf 2)$(tput bold) + format=$( { + tput AF 2 || tput setaf 2 + tput md || tput bold + } 2>/dev/null ) # For non-color terminals (!), just use bold else - format=$(tput bold) + format=$( { + tput md || tput bold + } 2>/dev/null ) fi # String it all together |