added variable to adjust escape commands

This commit is contained in:
pyr0ball 2022-03-23 08:44:16 -07:00
parent 5546c477ac
commit 2ea4529d00

View file

@ -2,32 +2,38 @@
# pyr0ball script functions library # pyr0ball script functions library
# Initial Vars # Initial Vars
scriptname=${0##*/} scriptname="${0##*/}"
rundir=${0%/*} rundir="${0%/*}"
runuser=$(whoami) runuser="$(whoami)"
pretty_date="`date +%Y-%m-%d_%H-%M-%S`"
# Utilities (Setting up colors and bounding boxes) # Utilities (Setting up colors and bounding boxes)
ESC=$( printf "\033")
if [[ "$TERM" != "linux" ]] ; then if [[ "$TERM" != "linux" ]] ; then
red=$(echo -e "\033[38;5;1m") # red red=$(echo -e "${ESC}[38;5;1m") # red
grn=$(echo -e "\033[38;5;2m") # green grn=$(echo -e "${ESC}[38;5;2m") # green
ylw=$(echo -e "\033[38;5;3m") # yellow ylw=$(echo -e "${ESC}[38;5;3m") # yellow
blu=$(echo -e "\033[38;5;27m") # blue blu=$(echo -e "${ESC}[38;5;27m") # blue
lbl=$(echo -e "\033[38;5;69m") # light blue lbl=$(echo -e "${ESC}[38;5;69m") # light blue
mag=$(echo -e "\033[38;5;5m") # magenta mag=$(echo -e "${ESC}[38;5;5m") # magenta
cyn=$(echo -e "\033[38;5;6m") # cyan cyn=$(echo -e "${ESC}[38;5;6m") # cyan
pur=$(echo -e "\033[38;5;135m") # purple pur=$(echo -e "${ESC}[38;5;135m") # purple
ong=$(echo -e "\033[38;5;166m") # orange ong=$(echo -e "${ESC}[38;5;166m") # orange
lyl=$(echo -e "\033[38;5;228m") # light yellow lyl=$(echo -e "${ESC}[38;5;228m") # light yellow
lrd=$(echo -e "\033[38;5;196m") # light red lrd=$(echo -e "${ESC}[38;5;196m") # light red
norm=$(echo -e "\033[38;5;9m") # default/normal norm=$(echo -e "${ESC}[38;5;9m") # default/normal
# #
bld=$(echo -e "\033[1m") # bold bld=$(echo -e "${ESC}[1m") # bold
unl=$(echo -e "\033[4m") # underline unl=$(echo -e "${ESC}[4m") # underline
blk=$(echo -e "\033[7m") # blinking not supported in our xterm, so reverse instead blk=$(echo -e "${ESC}[7m") # blinking not supported in our xterm, so reverse instead
nln=$(echo -e "\033[24") nln=$(echo -e "${ESC}[24") # not-underline
dfl=$(echo -e "\e[0m") dfl=$(echo -e "${ESC}[0m") # restore default
fi fi
# Extra Unicode Character Manipulation
return_arrow=$(echo -e '\u21B6')
enter_arrow$(echo -e '\u21B5')
# For drawing pretty boxes # For drawing pretty boxes
terminal_width=$(tput cols) terminal_width=$(tput cols)
if [ $terminal_width -le 81 ] ; then if [ $terminal_width -le 81 ] ; then
@ -35,6 +41,7 @@ if [ $terminal_width -le 81 ] ; then
else else
BOXWIDTH=80 BOXWIDTH=80
fi fi
# ---------------------------------------#
top_border=$(echo -e '\u2501') top_border=$(echo -e '\u2501')
left_border=$(echo -e '\u2503') left_border=$(echo -e '\u2503')
right_border=$(echo -e '\u2503') right_border=$(echo -e '\u2503')
@ -42,7 +49,8 @@ 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')
# ---------------------------------------#
top_double
repchar() { repchar() {
n=1 n=1
while [ $n -le $2 ] ; do while [ $n -le $2 ] ; do
@ -228,7 +236,6 @@ select_opt(){
multiselect(){ multiselect(){
# little helpers for terminal print control and key input # little helpers for terminal print control and key input
ESC=$( printf "\033")
cursor_blink_on() { printf "$ESC[?25h"; } cursor_blink_on() { printf "$ESC[?25h"; }
cursor_blink_off() { printf "$ESC[?25l"; } cursor_blink_off() { printf "$ESC[?25l"; }
cursor_to() { printf "$ESC[$1;${2:-1}H"; } cursor_to() { printf "$ESC[$1;${2:-1}H"; }