Updated to current

This commit is contained in:
edwark43
2025-02-07 15:18:20 -05:00
parent c79881b41c
commit 4e391f7e4b
26 changed files with 192 additions and 126 deletions

View File

@@ -1,25 +1,33 @@
#!/usr/bin/env bash
# Simple CLI for shell-color-scripts
DIR_COLORSCRIPTS="$HOME/.local/share/asciiart"
fmt_help=" %-20s\t%-54s\n"
list_colorscripts="$(/usr/bin/ls "${DIR_COLORSCRIPTS}" | cut -d ' ' -f 1 | nl)"
length_colorscripts="$(/usr/bin/ls "${DIR_COLORSCRIPTS}" | wc -l)"
function _help() {
echo "Description: A collection of terminal color scripts."
echo ""
echo "Usage: colorscript [OPTION] [SCRIPT NAME/INDEX]"
printf "${fmt_help}" \
"-h, --help, help" "Print this help." \
"-l, --list, list" "List all installed color scripts." \
"-r, --random, random" "Run a random color script." \
"-e, --exec, exec" "Run a specified color script by SCRIPT NAME or INDEX."
}
function _list() {
echo "There are "$(ls "${DIR_COLORSCRIPTS}" | wc -l)" installed color scripts:"
echo "${list_colorscripts}"
}
function _random() {
declare -i random_index=$RANDOM%$length_colorscripts
declare -i random_index=$((RANDOM % length_colorscripts + 1))
[[ $random_index -eq 0 ]] && random_index=1
random_colorscript="$(echo "${list_colorscripts}" | sed -n ${random_index}p \
| tr -d ' ' | tr '\t' ' ' | cut -d ' ' -f 2)"
# echo "${random_colorscript}"
exec "${DIR_COLORSCRIPTS}/${random_colorscript}"
}
@@ -67,6 +75,9 @@ case "$#" in
-h | --help | help)
_help
;;
-l | --list | list)
_list
;;
-r | --random | random)
_random
;;