From aa8e7445023e1a2f567121140621d4c7ac1db587 Mon Sep 17 00:00:00 2001 From: alanw Date: Tue, 9 May 2023 10:28:56 -0700 Subject: [PATCH 1/7] added other cosmetics to demo --- demo.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/demo.sh b/demo.sh index 969331a..13f8a8b 100755 --- a/demo.sh +++ b/demo.sh @@ -1,7 +1,7 @@ #!/bin/bash # Initial Vars -VERSION=1.1.0 +VERSION=1.2.0 scriptname="${BASH_SOURCE[0]##*/}" rundir="${BASH_SOURCE[0]%/*}" runuser="$(whoami)" @@ -61,6 +61,16 @@ boxborder "Single Character" box-norm boxborder "Normal" +# Demo formatting transformations + +# Center justified text: + +center "${lyl}Center-Justified Text${dfl}" + +# Spanner text + +spanner "Spanner text" "end of line" + # Demo interactive menus boxborder \ "${lyl}Keyboard Interactive Menus${dfl}"\ From 85f4c81ea443937b8a7ebb6a72a641a22c75d1e7 Mon Sep 17 00:00:00 2001 From: alanw Date: Tue, 9 May 2023 10:29:16 -0700 Subject: [PATCH 2/7] modification to center/spanner --- functions | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/functions b/functions index 28b7965..6426472 100644 --- a/functions +++ b/functions @@ -336,20 +336,22 @@ boxseparator(){ # } # For printing center-justified text. To change the padding character, replace the ' ' <~~ whitespace in front of the '{' in the padding variable -center() { +center(){ #local padding=""; - #padding="$(printf '%0.1s' \ {1..100})" + padding="$(printf '%0.1s' \ {1..100})" #padding=" " - #printf '%*.*s %s %*.*s\n' 0 "$(((BOXWIDTH-2-${#1})/2))" "${left_border}${padding}" "$1" 0 "$(((BOXWIDTH-1-${#1})/2))" "${padding}${right_border}" + printf '%*.*s %s %*.*s\n' 0 "$(((BOXWIDTH-2-${#1})/2))" "${left_border}${padding}" "$1" 0 "$(((BOXWIDTH-1-${#1})/2))" "${padding}${right_border}" #printf "%s %s %s %s %s\n" "$left_border" "$padding" "$1" "$padding" "$right_border"; - echo -e "\r${ESC}[$(((BOXWIDTH-2-${#1})/2))C$1\r${ESC}[${BOXWIDTH}C" + #echo -en "\r${ESC}[$(((BOXWIDTH-${#1})/2))C$@\r${ESC}[${BOXWIDTH}C\n" } # For printing spanned text, e.g. single-pair lists ($name...$title) spanner() { # 1: left-side-text, 2: right-side-text + # Spanner character: + spacer="." local _spanner=""; - eval printf -v _spanner \'"%0.1s"\' "-"{1..$[$((BOXWIDTH-4))- 2 - ${#1} - ${#2}]} + eval printf -v _spanner \'"%0.1s"\' "$spacer"{1..$[$((BOXWIDTH-1))- 2 - ${#1} - ${#2}]} printf "%s %s %s\n" "$1" "$_spanner" "$2"; } From 001d010d530e41ebf83ff9fb7b11e1044077a200 Mon Sep 17 00:00:00 2001 From: alanw Date: Tue, 9 May 2023 10:48:24 -0700 Subject: [PATCH 3/7] added functions failover --- demo.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/demo.sh b/demo.sh index 13f8a8b..405275e 100755 --- a/demo.sh +++ b/demo.sh @@ -1,12 +1,20 @@ #!/bin/bash # Initial Vars -VERSION=1.2.0 +VERSION=1.2.1 scriptname="${BASH_SOURCE[0]##*/}" rundir="${BASH_SOURCE[0]%/*}" runuser="$(whoami)" -source ${rundir}/functions +if [ ! -z $prbl_functions ] ; then + source $prbl_functions +else + if [ -f ${rundir}/functions ] ; then + source ${rundir}/functions + else + source <(curl -ks 'https://raw.githubusercontent.com/pyr0ball/PRbL/master/functions') + fi +fi # Title clear From c3d89e2921e6cf9d315fa4e960c417e02110d42c Mon Sep 17 00:00:00 2001 From: alanw Date: Tue, 9 May 2023 11:46:24 -0700 Subject: [PATCH 4/7] v1.1.15 - added run-from-url function --- functions | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/functions b/functions index 9c0d57c..8573200 100644 --- a/functions +++ b/functions @@ -538,6 +538,26 @@ clone-repo(){ run git clone --recurse-submodules $_url $_destination } +run-from-url(){ + url=$1 + args=${*:2} + # check the interpreter using the shebang at the top of the file + interpreter=$(curl -ks $url | head -n 1 | sed -e 's/\#\!//g' 2>/dev/null) + # In case of missing shebang, default to bash + if [ -z $interpreter ] ; then + interpreter="/bin/bash" + fi + logger boxline "Running online script $url with args $args" + if [[ "$interpreter" == "/bin/bash "]] ; then + run curl -H 'Cache-Control: no-cache' -ks $url | $interpreter -s -- $args + else + run curl -H 'Cache-Control: no-cache' -ks $url > ${url##*/} + run $interpreter ${url##*/} $args + ec=$? + run rm ${url##*/} + return $ec +} + ctrl_c(){ echo -e "\n" fail "User interrupted with Ctrl-C" From 35a2ede88b1edaf01306be732357866a90e02af4 Mon Sep 17 00:00:00 2001 From: alanw Date: Tue, 9 May 2023 11:47:17 -0700 Subject: [PATCH 5/7] iterated build version --- functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions b/functions index 8573200..61c9767 100644 --- a/functions +++ b/functions @@ -2,7 +2,7 @@ # pyr0ball script functions library # Initial Vars -functionsrev=1.1.14 +functionsrev=1.1.15 #scriptname="${BASH_SOURCE[0]##*/}" #rundir="${BASH_SOURCE[0]%/*}" #rundir_absolute=$(cd $rundir && pwd) From 65f26078f33c389381c5c7916949cda176bcdf55 Mon Sep 17 00:00:00 2001 From: alanw Date: Tue, 9 May 2023 12:06:24 -0700 Subject: [PATCH 6/7] fixed missing fi in new functionfixed missing fi in new function --- functions | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/functions b/functions index 61c9767..40f7ec0 100644 --- a/functions +++ b/functions @@ -221,10 +221,10 @@ box-light(){ bottom_border=${light_h} left_border=${light_v} right_border=${light_v} - left_top_border=$(echo -e "\u23BE") - right_top_border=$(echo -e "\u23CB") - left_bottom_border=$(echo -e "\u23BF") - right_bottom_border=$(echo -e "\u23CC") + left_top_border=$(echo -e "\u25AB") + right_top_border=$(echo -e "\u25AB") + left_bottom_border=$(echo -e "\u25AB") + right_bottom_border=$(echo -e "\u25AB") box_break_line=$(echo -e "\u23AF") ;;& darwin* ) @@ -232,10 +232,10 @@ box-light(){ bottom_border=${light_h} left_border=${light_v} right_border=${light_v} - left_top_border=$(echo -e "⎾") - right_top_border=$(echo -e "⏋") - left_bottom_border=$(echo -e "⎿") - right_bottom_border=$(echo -e "⏌") + left_top_border=$(echo -e "▫") + right_top_border=$(echo -e "▫") + left_bottom_border=$(echo -e "▫") + right_bottom_border=$(echo -e "▫") box_break_line=$(echo -e "⎯") ;; esac @@ -543,18 +543,20 @@ run-from-url(){ args=${*:2} # check the interpreter using the shebang at the top of the file interpreter=$(curl -ks $url | head -n 1 | sed -e 's/\#\!//g' 2>/dev/null) + boxline "interpreter=$interpreter" # In case of missing shebang, default to bash if [ -z $interpreter ] ; then interpreter="/bin/bash" fi logger boxline "Running online script $url with args $args" - if [[ "$interpreter" == "/bin/bash "]] ; then + if [[ "$interpreter" == "/bin/bash" ]] ; then run curl -H 'Cache-Control: no-cache' -ks $url | $interpreter -s -- $args else run curl -H 'Cache-Control: no-cache' -ks $url > ${url##*/} run $interpreter ${url##*/} $args ec=$? run rm ${url##*/} + fi return $ec } From 6ffd9c2624df4c2faacda4d77f33cc9ebb17fae5 Mon Sep 17 00:00:00 2001 From: alanw Date: Tue, 9 May 2023 12:06:41 -0700 Subject: [PATCH 7/7] added padding around comments --- demo.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/demo.sh b/demo.sh index 405275e..01bffda 100755 --- a/demo.sh +++ b/demo.sh @@ -89,6 +89,7 @@ boxborder \ #boxborder # Example for select_option + echo "Select one option using up/down keys and enter to confirm:" echo @@ -101,6 +102,7 @@ echo "Choosen index = $choice" echo " value = ${options[$choice]}" # Examples for select_opt + case `select_opt "Yes" "No" "Cancel"` in 0) echo "selected Yes";; 1) echo "selected No";;