From 5f03d14a14ae9b7b1ee065904b195375bc567f1f Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Thu, 13 Jul 2023 17:44:52 -0400 Subject: [PATCH] tagger.sh: add colors --- src/.local/bin/tagger.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/.local/bin/tagger.sh b/src/.local/bin/tagger.sh index a21f8b0..52648d4 100755 --- a/src/.local/bin/tagger.sh +++ b/src/.local/bin/tagger.sh @@ -1,11 +1,15 @@ #!/bin/sh # wrapper over tmsu for easy tagging -# -# takes in file paths via stdin to tag -# pipe in `tmsu untagged` to tag untagged files +# tags untagged files for the database in the current working directory set -e +if [ -z "$NO_COLOR" ]; then + COL_LIGHT_BLUE="$(tput setaf 12)" + COL_LIGHT_PURPLE="$(tput setaf 13)" + COL_RESET="$(tput sgr0)" +fi + # read -n 1 isn't POSIX-compliant so we implement something # https://unix.stackexchange.com/questions/464930/can-i-read-a-single-character-from-stdin-in-posix-shell @@ -40,9 +44,7 @@ editargs() { appendargs() { while true; do - RES="$(tmsu tags \ - | fzf -m --print-query --header "Select tag (or write 'tagname+' or any other special character to create a new tag)" \ - || true)" + RES="$(tmsu tags | fzf -m --print-query --header "Select tag (or write 'tagname+' or any other special character to create a new tag)" || true)" if [ -z "$RES" ]; then break @@ -73,9 +75,10 @@ while read -r FILE; do appendargs while true; do - printf "%s\n" "$FILE" - printf "tagging %s with tags:\n" "$FILE" + printf "\n\ntagging %s%s%s with tags:\n" "$COL_LIGHT_BLUE" "$FILE" "$COL_RESET" + printf "$COL_LIGHT_PURPLE" cat "$TMSU_ARGS" | sed 's/^/- /' + printf "$COL_RESET" printf "\nh view again, j add tmsu args, k edit tmsu args, l confirm, q exit, s skip\n" printf "\n> " ANS="$(readc