From 8c841c1d8c1c72978167c16bbb192348d0d483f4 Mon Sep 17 00:00:00 2001 From: "Fred T. Hamster" Date: Wed, 4 Dec 2024 20:22:56 -0500 Subject: [PATCH] fixed separator method to support character choice separator now accepts a count and a character string, so like: $ sep 4 "arf-" generates: arf-arf-arf-arf- nice! and fixed 's' alias to use separator function instead of being a hard-coded line of pound signs. --- scripts/core/common.alias | 2 +- scripts/core/functions.sh | 28 +++++++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/scripts/core/common.alias b/scripts/core/common.alias index ed7bc6e5..7fe8c02d 100644 --- a/scripts/core/common.alias +++ b/scripts/core/common.alias @@ -83,7 +83,7 @@ define_yeti_alias rd='perl $FEISTY_MEOW_SCRIPTS/files/zapdirs.pl' define_yeti_alias ren='\mv -v -i' define_yeti_alias rm='perl $FEISTY_MEOW_SCRIPTS/files/safedel.pl' define_yeti_alias rmdir='perl $FEISTY_MEOW_SCRIPTS/files/zapdirs.pl' -define_yeti_alias s='echo "##############"' +define_yeti_alias s='sep 14 "#"' define_yeti_alias path='echo $PATH' define_yeti_alias whence=which diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index c99cb0b6..c62885ee 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -790,22 +790,32 @@ return 0 ############## - # just shows a separator line for an 80 column console, or uses the first - # parameter as the number of columns to expect. + # just shows a separator line for the current console size, or uses the first + # parameter as the number of columns to expect. if a second parameter is provided, + # then that is used as the separator character(s). function separator() { count=$1; shift if [ -z "$count" ]; then count=$(($COLUMNS - 1)) fi - echo - local i - for ((i=0; i < $count; i++)); do - echo -n "=" - done - echo - echo + + # snag remaining paramters into the characters to show. + characters="${@}" + if [ -z "$characters" ]; then + characters="=" + fi + +#hmmm: works, but has flaw of disallowing spaces within the characters variable. +# local garptemp="$(printf '%*s' "$count")" +# local emission="${garptemp// /${characters}}" + + local garptemp="$(dd if=/dev/zero bs="$count" count=1 2>/dev/null | tr '\0' 'Q')" + local emission="${garptemp//Q/${characters}}" + + echo "$emission" } + # alias for separator. function sep() { -- 2.34.1