diff options
author | Derek Taylor <derek@distrotube.com> | 2022-02-21 13:52:20 -0600 |
---|---|---|
committer | Derek Taylor <derek@distrotube.com> | 2022-02-21 13:52:20 -0600 |
commit | 6e4a4184ae482dcdeb9c62ab39d07b3b0a2eae04 (patch) | |
tree | 1ad5907d7929eef436798b0df8bec172ff0f89c1 | |
parent | Separating animated and non-animated colorscripts. (diff) |
Changed mind on separating animated and non-animated.
-rw-r--r-- | colorscript.1 | 15 | ||||
-rwxr-xr-x | colorscript.sh | 86 | ||||
-rwxr-xr-x | colorscripts/bomber (renamed from animated-colorscripts/bomber) | 0 | ||||
-rwxr-xr-x | colorscripts/pipes1 (renamed from animated-colorscripts/pipes1) | 0 | ||||
-rwxr-xr-x | colorscripts/pipes2 (renamed from animated-colorscripts/pipes2) | 0 | ||||
-rwxr-xr-x | colorscripts/pipes2-slim (renamed from animated-colorscripts/pipes2-slim) | 0 |
6 files changed, 11 insertions, 90 deletions
diff --git a/colorscript.1 b/colorscript.1 index c1a472c..e4eb4a2 100644 --- a/colorscript.1 +++ b/colorscript.1 @@ -18,22 +18,13 @@ colorscript is the program that selects and runs the scripts that were installed Print this help. .SS "-l, --list, list" .PP -List all installed colorscripts. +List all installed color scripts. .SS "-r, --random, random" .PP -Run a random NON-ANIMATED colorscript. -.SS "-R, --random-animated, random-animated" -.PP -Run a random ANIMATED color script. +Run a random color script. .SS "-e, --exec, exec" .PP -Run specified NON-ANIMATED colorscript by SCRIPT NAME or INDEX. -.SS "-E, --exec-animated, exec-animated" -.PP -Run specified ANIAMTED colorscript by SCRIPT NAME or INDEX. -.SS "-a, --all, all" -.PP -Print all NON-ANIMATED colorscripts with their script name. +Run specified color script by SCRIPT NAME or INDEX. .SH "FILES" .SS "/usr/bin/colorscript" diff --git a/colorscript.sh b/colorscript.sh index a053f73..3d30375 100755 --- a/colorscript.sh +++ b/colorscript.sh @@ -9,19 +9,9 @@ else LS_CMD="$(command -v ls) ${DIR_COLORSCRIPTS}" fi -DIR_ANIMATED_COLORSCRIPTS="/opt/shell-color-scripts/animated-colorscripts" -if command -v find &>/dev/null; then - LS_CMD_ANIMATED="$(command -v find) ${DIR_ANIMATED_COLORSCRIPTS} -maxdepth 1 -type f" -else - LS_CMD_ANIMATED="$(command -v ls) ${DIR_ANIMATED_COLORSCRIPTS}" -fi - list_colorscripts="$($LS_CMD | xargs -I $ basename $ | cut -d ' ' -f 1 | nl)" length_colorscripts="$($LS_CMD | wc -l)" -list_colorscripts_animated="$($LS_CMD_ANIMATED | xargs -I $ basename $ | cut -d ' ' -f 1 | nl)" -length_colorscripts_animated="$($LS_CMD_ANIMATED | wc -l)" - fmt_help=" %-20s\t%-54s\n" function _help() { echo "Description: A collection of terminal color scripts." @@ -29,25 +19,15 @@ function _help() { echo "Usage: colorscript [OPTION] [SCRIPT NAME/INDEX]" printf "${fmt_help}" \ "-h, --help, help" "Print this help." \ - "-l, --list, list" "List all installed colorscripts." \ - "-r, --random, random" "Run a random NON-ANIMATED colorscript." \ - "-R, --random-animated, random-animated" "Run a random ANIMATED colorscript." \ - "-e, --exec, exec" "Run a specified NON-ANIMATED colorscript by SCRIPT NAME or INDEX."\ - "-E, --exec-animated, exec-animated" "Run a specified ANIMATED colorscript by SCRIPT NAME or INDEX."\ - "-b, --blacklist, blacklist" "Blacklist a colorscript by SCRIPT NAME or INDEX." \ - "-a, --all, all" "List the outputs of all NON-ANIMATED colorscripts with their SCRIPT NAME" + "-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."\ + "-b, --blacklist, blacklist" "Blacklist a color script by SCRIPT NAME or INDEX." \ + "-a, --all, all" "List the outputs of all colorscripts with their SCRIPT NAME" } function _list() { - echo "--------------------------------------------------" - echo "There are "$($LS_CMD_ANIMATED | wc -l)" ANIMATED colorscripts. Run with:" - echo " colorscript -E name-or-index" - echo "--------------------------------------------------" - echo "${list_colorscripts_animated}" - echo "--------------------------------------------------" - echo "There are "$($LS_CMD | wc -l)" NON-ANIMATED colorscripts. Run with:" - echo " colorscript -e name-or-index" - echo "--------------------------------------------------" + echo "There are "$($LS_CMD | wc -l)" installed color scripts:" echo "${list_colorscripts}" } @@ -61,24 +41,10 @@ function _random() { exec "${DIR_COLORSCRIPTS}/${random_colorscript}" } -function _random_animated() { - declare -i random_index=$RANDOM%$length_colorscripts - [[ $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_ANIMATED_COLORSCRIPTS}/${random_colorscript}" -} - function ifhascolorscipt() { [[ -e "${DIR_COLORSCRIPTS}/$1" ]] && echo "Has this color script." } -function ifhascolorscipt_animated() { - [[ -e "${DIR_ANIMATED_COLORSCRIPTS}/$1" ]] && echo "Has this color script." -} - function _run_by_name() { if [[ "$1" == "random" ]]; then _random @@ -90,17 +56,6 @@ function _run_by_name() { fi } -function _run_by_name_animated() { - if [[ "$1" == "random" ]]; then - _random - elif [[ -n "$(ifhascolorscipt_animated "$1")" ]]; then - exec "${DIR_ANIMATED_COLORSCRIPTS}/$1" - else - echo "Input error, Don't have color script named $1." - exit 1 - fi -} - function _run_by_index() { if [[ "$1" -gt 0 && "$1" -le "${length_colorscripts}" ]]; then @@ -108,19 +63,7 @@ function _run_by_index() { | tr -d ' ' | tr '\t' ' ' | cut -d ' ' -f 2)" exec "${DIR_COLORSCRIPTS}/${colorscript}" else - echo "Input error, Don't have NON-ANIMATED color script indexed $1." - exit 1 - fi -} - -function _run_by_index_animated() { - if [[ "$1" -gt 0 && "$1" -le "${length_colorscripts_animated}" ]]; then - - colorscript="$(echo "${list_colorscripts_animated}" | sed -n ${1}p \ - | tr -d ' ' | tr '\t' ' ' | cut -d ' ' -f 2)" - exec "${DIR_ANIMATED_COLORSCRIPTS}/${colorscript}" - else - echo "Input error, Don't have ANIMATED color script indexed $1." + echo "Input error, Don't have color script indexed $1." exit 1 fi } @@ -133,14 +76,6 @@ function _run_colorscript() { fi } -function _run_animated_colorscript() { - if [[ "$1" =~ ^[0-9]+$ ]]; then - _run_by_index_animated "$1" - else - _run_by_name_animated "$1" - fi -} - function _run_all() { for s in $DIR_COLORSCRIPTS/* do @@ -169,12 +104,9 @@ case "$#" in -l | --list | list) _list ;; - -r | --random-static | random) + -r | --random | random) _random ;; - -R | --random-animated | random-animated) - _random_animated - ;; -a | --all | all) _run_all ;; @@ -187,8 +119,6 @@ case "$#" in 2) if [[ "$1" == "-e" || "$1" == "--exec" || "$1" == "exec" ]]; then _run_colorscript "$2" - elif [[ "$1" == "-E" || "$1" == "--exec-animated" || "$1" == "exec-animated" ]]; then - _run_animated_colorscript "$2" elif [[ "$1" == "-b" || "$1" == "--blacklist" || "$1" == "blacklist" ]]; then _blacklist_colorscript "$2" else diff --git a/animated-colorscripts/bomber b/colorscripts/bomber index 3c632ed..3c632ed 100755 --- a/animated-colorscripts/bomber +++ b/colorscripts/bomber diff --git a/animated-colorscripts/pipes1 b/colorscripts/pipes1 index 70a751e..70a751e 100755 --- a/animated-colorscripts/pipes1 +++ b/colorscripts/pipes1 diff --git a/animated-colorscripts/pipes2 b/colorscripts/pipes2 index c658f37..c658f37 100755 --- a/animated-colorscripts/pipes2 +++ b/colorscripts/pipes2 diff --git a/animated-colorscripts/pipes2-slim b/colorscripts/pipes2-slim index 7b26506..7b26506 100755 --- a/animated-colorscripts/pipes2-slim +++ b/colorscripts/pipes2-slim |