Merge branch 'master' of https://github.com/pyr0ball/PRbL
This commit is contained in:
commit
a2aabfb78f
2 changed files with 12 additions and 12 deletions
|
|
@ -15,6 +15,4 @@ With all of these tools combined, you can make powerful interactive scripts with
|
|||
|
||||
run `./demo.sh` for example output
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
|
|
|||
20
functions
20
functions
|
|
@ -2,7 +2,7 @@
|
|||
# pyr0ball script functions library
|
||||
|
||||
# Initial Vars
|
||||
functionsrev=1.1.10
|
||||
functionsrev=1.1.11
|
||||
#scriptname="${BASH_SOURCE[0]##*/}"
|
||||
#rundir="${BASH_SOURCE[0]%/*}"
|
||||
#rundir_absolute=$(cd $rundir && pwd)
|
||||
|
|
@ -337,19 +337,18 @@ boxseparator(){
|
|||
|
||||
# For printing center-justified text. To change the padding character, replace the ' ' <~~ whitespace in front of the '{' in the padding variable
|
||||
center() {
|
||||
local _cmd=$@
|
||||
local padding="";
|
||||
padding="$(printf '%0.1s' \ {1..100})"
|
||||
#padding=" "
|
||||
printf '%*.*s %s %*.*s\n' 0 "$(((BOXWIDTH-2-${#_cmd[@]})/2))" "${padding}" "$_cmd" 0 "$(((BOXWIDTH-1-${#_cmd})/2))" "${padding}"
|
||||
printf '%*.*s %s %*.*s\n' 0 "$(((BOXWIDTH-2-${#1})/2))" "${padding}" "$1" 0 "$(((BOXWIDTH-1-${#1})/2))" "${padding}"
|
||||
}
|
||||
|
||||
# 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-4))- 2 - ${#1} - ${#2}]}
|
||||
printf "%s %s %s\n" "$1" "$spanner" "$2";
|
||||
local _spanner="";
|
||||
eval printf -v _spanner \'"%0.1s"\' "-"{1..$[$((BOXWIDTH-4))- 2 - ${#1} - ${#2}]}
|
||||
printf "%s %s %s\n" "$1" "$_spanner" "$2";
|
||||
}
|
||||
|
||||
boxborder(){
|
||||
|
|
@ -413,11 +412,14 @@ popdfail(){
|
|||
}
|
||||
|
||||
logger(){
|
||||
#$@ 2>&1 | tee >(ts "[$scriptname][%d-%m-%y %H_%M_%S]" > $logfile) # This version of prepend requires the 'ts' utility from 'moreutils' package
|
||||
$@ 2>&1 | tee >(
|
||||
while IFS= read -r line; do
|
||||
_line=$(echo $line | sed "s,\x1B\[[0-9;]*[mK],,g" | tr -dc '[:print:]')
|
||||
printf '[%s] %s\n' "${scriptname}][${prettyDate}" "$_line"
|
||||
# strip any escaped strings for logging output
|
||||
_line=$(echo $line | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | tr -dc '[:print:]')
|
||||
# only print out non-empty lines to log
|
||||
if [[ "$_line" != "" ]] ; then
|
||||
printf '[%s] %s\n' "${scriptname}][${pretty_date}" "$_line"
|
||||
fi
|
||||
done >> $logfile
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue