mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-30 09:40:09 +00:00
fix extraction method Associative Array
This commit is contained in:
parent
0a1acbb5d5
commit
6ce4571704
1 changed files with 15 additions and 4 deletions
|
@ -128,8 +128,12 @@ elif [[ $color_flag ]] || [[ $u_flag ]] || \
|
||||||
|
|
||||||
if [[ $color_flag ]]; then
|
if [[ $color_flag ]]; then
|
||||||
test_input $color_flag[2]
|
test_input $color_flag[2]
|
||||||
|
# Set internal flag so script knows to use built in colors,
|
||||||
|
# rather than looking for passed in RGB values
|
||||||
USED_BUILTIN=1
|
USED_BUILTIN=1
|
||||||
BUILT_IN_COLOR=$built_in_colors[$color_flag[2]]
|
# Extract RGB color code from $built_in_colors associative array
|
||||||
|
# corresponding to built in color requested by user
|
||||||
|
BUILT_IN_COLOR=(${(ps: :)${built_in_colors[$color_flag[2]]}})
|
||||||
fi
|
fi
|
||||||
if [[ $u_flag ]]; then
|
if [[ $u_flag ]]; then
|
||||||
UL="\033[4m" # underline
|
UL="\033[4m" # underline
|
||||||
|
@ -148,28 +152,35 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If built in color was used, set the RGB value to those
|
||||||
|
# that correspond with the built in color
|
||||||
if [[ $USED_BUILTIN == 1 ]]; then
|
if [[ $USED_BUILTIN == 1 ]]; then
|
||||||
R=$BUILT_IN_COLOR[1,3]
|
R=$BUILT_IN_COLOR[1]
|
||||||
G=$BUILT_IN_COLOR[5,7]
|
G=$BUILT_IN_COLOR[2]
|
||||||
B=$BUILT_IN_COLOR[9,11]
|
B=$BUILT_IN_COLOR[3]
|
||||||
MSG=$@
|
MSG=$@
|
||||||
else
|
else
|
||||||
|
# If user supplied RGB values, assign them to R G B
|
||||||
if [[ $# == 4 ]]; then
|
if [[ $# == 4 ]]; then
|
||||||
R=$1
|
R=$1
|
||||||
G=$2
|
G=$2
|
||||||
B=$3
|
B=$3
|
||||||
MSG=$4
|
MSG=$4
|
||||||
|
# If no color options were specified, use white by default
|
||||||
elif [[ $# == 1 ]]; then
|
elif [[ $# == 1 ]]; then
|
||||||
R=255
|
R=255
|
||||||
G=255
|
G=255
|
||||||
B=255
|
B=255
|
||||||
MSG=$1
|
MSG=$1
|
||||||
else
|
else
|
||||||
|
# If something went wrong show the usage message and exit
|
||||||
usage
|
usage
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $n_flag ]]; then
|
if [[ $n_flag ]]; then
|
||||||
|
# If -n options is given, use -n with internal echo command
|
||||||
echo -n "${UL}${BD}${IT}\033[38;2;${R};${G};${B}m${MSG}${RS}"
|
echo -n "${UL}${BD}${IT}\033[38;2;${R};${G};${B}m${MSG}${RS}"
|
||||||
else
|
else
|
||||||
echo "${UL}${BD}${IT}\033[38;2;${R};${G};${B}m${MSG}${RS}"
|
echo "${UL}${BD}${IT}\033[38;2;${R};${G};${B}m${MSG}${RS}"
|
||||||
|
|
Loading…
Reference in a new issue