From 3769b3cc5c3808589f3e00c305bdaa4552648998 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 12 Apr 2022 23:25:02 -0700 Subject: [PATCH 1/5] added spanner function --- functions | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/functions b/functions index 1e9b962..62d60d6 100644 --- a/functions +++ b/functions @@ -218,6 +218,21 @@ boxseparator(){ echo } +# For printing center-justified text. To change the padding character, replace the ' ' <~~ whitespace in front of the '{' in the padding variable +center() { + padding="$(printf '%0.2s' ={1..500})" + #padding=" " + printf '%*.*s %s %*.*s\n' 0 "$(((BOXWIDTH-2-${#1})/2))" "$left_border$padding" "$1" 0 "$(((BOXWIDTH-1-${#1})/2))" "$padding$right_border" +} + +# For printing spanned text, e.g. single-pair lists ($name...$title) +spanner() { + # 1: left-side-text, 2: right-side-text + local spanner=""; + eval printf -v spanner \'"%0.1s"\' "-"{1..$[$(BOXWIDTH)- 2 - ${#1} - ${#2}]} + printf "%s %s %s" "$1" "$spanner" "$2"; +} + boxborder(){ boxtop for line in "$@" ; do From a4446e4839f2824b20f5bd3131e8de5e26536ac6 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 13 Apr 2022 00:54:08 -0700 Subject: [PATCH 2/5] fixed width on spanner function --- functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions b/functions index 62d60d6..3321f2c 100644 --- a/functions +++ b/functions @@ -229,7 +229,7 @@ center() { spanner() { # 1: left-side-text, 2: right-side-text local spanner=""; - eval printf -v spanner \'"%0.1s"\' "-"{1..$[$(BOXWIDTH)- 2 - ${#1} - ${#2}]} + eval printf -v spanner \'"%0.1s"\' "-"{1..$[$((BOXWIDTH+24))- 2 - ${#1} - ${#2}]} printf "%s %s %s" "$1" "$spanner" "$2"; } From 41dac71283089e7dcb4aaed65850b70588988ab2 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 13 Apr 2022 01:35:12 -0700 Subject: [PATCH 3/5] fixed spanner width again --- functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions b/functions index 3321f2c..69645d0 100644 --- a/functions +++ b/functions @@ -229,7 +229,7 @@ center() { spanner() { # 1: left-side-text, 2: right-side-text local spanner=""; - eval printf -v spanner \'"%0.1s"\' "-"{1..$[$((BOXWIDTH+24))- 2 - ${#1} - ${#2}]} + eval printf -v spanner \'"%0.1s"\' "-"{1..$[$((BOXWIDTH+10))- 2 - ${#1} - ${#2}]} printf "%s %s %s" "$1" "$spanner" "$2"; } From e4186a0cc7bb60c9af250b76f3d1b4cf61076ed6 Mon Sep 17 00:00:00 2001 From: Alan Weinstock Date: Wed, 13 Apr 2022 10:42:36 -0700 Subject: [PATCH 4/5] updated readme --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 7e708cb..fd8393d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,16 @@ pyr0-bash-functions =============== + +A functions library for bash-like scripting + +Includes: + + - Colorization + - Text Formatting + - Bounding Box Drawing + - Logging + - User-interactable menus + +With all of these tools combined, you can make powerful interactive scripts with ease and pleasant form + +run `./demo.sh` for example output \ No newline at end of file From 7434e3989b550c79120051edb2aab28eef8452e6 Mon Sep 17 00:00:00 2001 From: Alan Weinstock Date: Wed, 13 Apr 2022 11:28:33 -0700 Subject: [PATCH 5/5] fixed markdown formatting --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fd8393d..31531a4 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,12 @@ A functions library for bash-like scripting Includes: - - Colorization - - Text Formatting - - Bounding Box Drawing - - Logging - - User-interactable menus +- Colorization +- Text Formatting +- Bounding Box Drawing +- Logging +- User-interactable menus With all of these tools combined, you can make powerful interactive scripts with ease and pleasant form -run `./demo.sh` for example output \ No newline at end of file +run `./demo.sh` for example output