tagger.sh: add colors

This commit is contained in:
dogeystamp 2023-07-13 17:44:52 -04:00
parent 7b8b099a88
commit 5f03d14a14
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38

View File

@ -1,11 +1,15 @@
#!/bin/sh #!/bin/sh
# wrapper over tmsu for easy tagging # wrapper over tmsu for easy tagging
# # tags untagged files for the database in the current working directory
# takes in file paths via stdin to tag
# pipe in `tmsu untagged` to tag untagged files
set -e 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 # 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 # https://unix.stackexchange.com/questions/464930/can-i-read-a-single-character-from-stdin-in-posix-shell
@ -40,9 +44,7 @@ editargs() {
appendargs() { appendargs() {
while true; do while true; do
RES="$(tmsu tags \ RES="$(tmsu tags | fzf -m --print-query --header "Select tag (or write 'tagname+' or any other special character to create a new tag)" || true)"
| 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 if [ -z "$RES" ]; then
break break
@ -73,9 +75,10 @@ while read -r FILE; do
appendargs appendargs
while true; do while true; do
printf "%s\n" "$FILE" printf "\n\ntagging %s%s%s with tags:\n" "$COL_LIGHT_BLUE" "$FILE" "$COL_RESET"
printf "tagging %s with tags:\n" "$FILE" printf "$COL_LIGHT_PURPLE"
cat "$TMSU_ARGS" | sed 's/^/- /' 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 "\nh view again, j add tmsu args, k edit tmsu args, l confirm, q exit, s skip\n"
printf "\n> " printf "\n> "
ANS="$(readc </dev/tty)" ANS="$(readc </dev/tty)"