mirror of
https://github.com/lloeki/dotfiles.git
synced 2025-12-06 07:24:39 +01:00
bash: set_color helper (bash 3+4)
This commit is contained in:
parent
e22a871ede
commit
5c386aa52d
5 changed files with 241 additions and 116 deletions
25
bash/ansi
Normal file
25
bash/ansi
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
if [[ $BASH_VERSINFO -gt 3 ]]; then
|
||||
source "$DOTFILES_BASH_DIR"/ansi4
|
||||
else
|
||||
source "$DOTFILES_BASH_DIR"/ansi3
|
||||
fi
|
||||
|
||||
setup_ansi_sgr_index
|
||||
|
||||
# set_color [-p] color
|
||||
# -p: wraps output for bash prompt size match
|
||||
set_color() {
|
||||
if [[ $1 == "-p" ]]; then
|
||||
local prompt=1
|
||||
shift
|
||||
fi
|
||||
local code=$1
|
||||
|
||||
[[ $prompt -eq 1 ]] && echo -n "\["
|
||||
echo -n "\033["
|
||||
ansi_sgr "$code"
|
||||
echo -n "m"
|
||||
[[ $prompt -eq 1 ]] && echo -n "\]"
|
||||
}
|
||||
|
||||
# vim: ft=sh
|
||||
Loading…
Add table
Add a link
Reference in a new issue