From a8468aaba5c50da7d878a4ef85bb9b4b70df2ab2 Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me> Date: Sun, 18 Oct 2020 12:25:08 -0400 Subject: [PATCH] changed -a behavior, text formatting --- charsel | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/charsel b/charsel index 170a386..9915519 100755 --- a/charsel +++ b/charsel @@ -19,7 +19,7 @@ ######################################################################## -VERSION=2.0.2 +VERSION=2.0.3 # Define argument functions function usage() { @@ -30,7 +30,7 @@ A simple terminal character selector -d show readme -v print version -c check charfile validity - --all include hidden shortcodes + -a include hidden shortcodes Exit status: 0 okay, @@ -104,7 +104,7 @@ function validity() { } # Look for arguments -while getopts ":lchdv" arg +while getopts ":alchdv" arg do case ${arg} in h) @@ -127,14 +127,14 @@ do validity exit 0 ;; + a) + SHOWALL="true" + ;; ?) echo "Invalid option" usage exit 3 ;; - :) - break - ;; esac done shift $((OPTIND-1)) @@ -159,22 +159,26 @@ LENGTH=$(cat $CHARFILE \ clear +# Define text formatting +bold=$(tput bold) +normal=$(tput sgr0) + # Main program while true do # Format output echo "*---------*---------------*" - echo "| CHARSEL |" $1 + echo "| ${bold}CHARSEL${normal} |" $1 echo "*---------*---------------*" echo "" - if [[ $2 == "--all" ]] + if [[ $SHOWALL == true ]] then cat $CHARFILE | sed -e '/^[ \t]*#/d' | tail -n +2 \ - | column -t -N input,output --output-separator ' | ' --separator ',' + | column -t -N "input","output" --output-separator ' | ' --separator ',' else cat $CHARFILE | sed -e '/^[ \t]*#/d' | grep -A 100 - | tail -n +2 \ - | column -t -N input,output --output-separator ' | ' --separator ',' + | column -t -N "input","output" --output-separator ' | ' --separator ',' fi echo "" @@ -184,7 +188,7 @@ do echo "*-------------------------*" # User input - read -p "| input shortcode: " -N $LENGTH INPUT + read -p "| ${bold}input shortcode: ${normal} " -N $LENGTH INPUT if [[ $INPUT == ";"* ]] # Semicolon exits then -- 2.39.2