added different escape handling for OSX

This commit is contained in:
pyr0ball 2022-07-03 12:45:42 -07:00
parent 7cd5f3b86d
commit 54d5a02a55

View file

@ -10,7 +10,18 @@ pretty_date="$(date +%Y-%m-%d_%H-%M-%S)"
# Escape characters (if your shell uses a different one, you can modify it here) # Escape characters (if your shell uses a different one, you can modify it here)
# By default this is using the usual bash escape code # By default this is using the usual bash escape code
ESC=$( printf "\033") ESC=$( printf '\033')
# Detect OS type
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
ESC=$( printf '\033')
elif [[ "$OSTYPE" == "darwin"* ]]; then
ESC=$( printf '\e')
elif [[ "$OSTYPE" == "cygwin" ]]; then
ESC=$( printf '\033')
else [[ "$OSTYPE" == "msys" ]]; then
ESC=$( printf '\033')
fi
# Utilities (Setting up colors and bounding boxes) # Utilities (Setting up colors and bounding boxes)
@ -48,19 +59,19 @@ if [[ "$TERM" != "linux" ]] ; then
blk=$(echo -e "${ESC}[5") # blinking blk=$(echo -e "${ESC}[5") # blinking
unbl=$(echo -e "${ESC}[25") # stop blinking unbl=$(echo -e "${ESC}[25") # stop blinking
inv=$(echo -e "${ESC}[7m") # invert inv=$(echo -e "${ESC}[7m") # invert
rsinv=$(echo -e "${ESC}[27") # reset invert rsinv=$(echo -e "${ESC}[27") # reset http://www.endmemo.com/unicode/unicodeconverter.phpnvert
hid=$(echo -e "${ESC}[8") # hidden hid=$(echo -e "${ESC}[8") # hidden
unh=$(echo -e "${ESC}[28") # unhide unh=$(echo -e "${ESC}[28") # unhide
dfl=$(echo -e "${ESC}[0m") # restore default dfl=$(echo -e "${ESC}[0m") # restore default
fi fi
# Extra Unicode Character Manipulation # Extra Unicode Character Manipulation
return_arrow=$(echo -e '\u2BAC') return_arrow=$(echo -e "\u2BAC")
enter_arrow=$(echo -e '\u21B5') enter_arrow=$(echo -e "\u21B5")
green_check=${grn}$(echo -e '\u2714')${dfl} green_check=${grn}$(echo -e "\u2714")${dfl}
red_x=${lrd}$(echo -e '\u00D7')${dfl} red_x=${lrd}$(echo -e "\u00D7")${dfl}
selected_opt=$(echo -e '\u25C9') selected_opt=$(echo -e "\u25C9")
deselected_opt=$(echo -e '\u25CE') deselected_opt=$(echo -e "\u25CE")
# For drawing pretty boxes # For drawing pretty boxes
terminal_width=$(tput cols) terminal_width=$(tput cols)
@ -77,12 +88,12 @@ center() {
} }
# Box Drawing characters # Box Drawing characters
light_h=$(echo -e '\u2500') light_h=$(echo -e "\u2500")
norm_h=$(echo -e '\u2501') norm_h=$(echo -e "\u2501")
double_h=$(echo -e '\u2550') double_h=$(echo -e "\u2550")
light_v=$(echo -e '\u2502') light_v=$(echo -e "\u2502")
norm_v=$(echo -e '\u2503') norm_v=$(echo -e "\u2503")
double_v=$(echo -e '\u2551') double_v=$(echo -e "\u2551")
# Box border type single-line # Box border type single-line
@ -92,11 +103,11 @@ box-norm(){
bottom_border=${norm_h} bottom_border=${norm_h}
left_border=${norm_v} left_border=${norm_v}
right_border=${norm_v} right_border=${norm_v}
left_top_border=$(echo -e '\u250f') left_top_border=$(echo -e "\u250f")
right_top_border=$(echo -e '\u2513') right_top_border=$(echo -e "\u2513")
left_bottom_border=$(echo -e '\u2517') left_bottom_border=$(echo -e "\u2517")
right_bottom_border=$(echo -e '\u251b') right_bottom_border=$(echo -e "\u251b")
box_break_line=$(echo -e '\u25AB') box_break_line=$(echo -e "\u25AB")
# ---------------------------------------# # ---------------------------------------#
} }