fixed separator method to support character choice
authorFred T. Hamster <fred@gruntose.com>
Thu, 5 Dec 2024 01:22:56 +0000 (20:22 -0500)
committerFred T. Hamster <fred@gruntose.com>
Thu, 5 Dec 2024 01:22:56 +0000 (20:22 -0500)
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
scripts/core/functions.sh

index ed7bc6e57cded0f77978c3ce1ff1e5f98ead0d5a..7fe8c02da3fbc5a86280bf6eaf5dd149a9eac14e 100644 (file)
@@ -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
 
index c99cb0b6ff305de050d2cd176f235f7eef25c528..c62885ee4ca4b2bfaf1f4131f115ac2fbbdbd89d 100644 (file)
@@ -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()
   {