From 25a461920325f20f12d8417f349de80e74a214aa Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Mon, 22 Dec 2025 00:29:29 -0500 Subject: [PATCH] minor improvements --- .gemrc | 2 -- beetag | 24 ++++++++++++++---------- brc | 13 +++++++++++++ brc2 | 27 +++++++-------------------- fsf-script-lib | 7 +++++++ 5 files changed, 41 insertions(+), 32 deletions(-) delete mode 100644 .gemrc diff --git a/.gemrc b/.gemrc deleted file mode 100644 index d90ed0f..0000000 --- a/.gemrc +++ /dev/null @@ -1,2 +0,0 @@ -# if a gem fails on documentation, uncomment this. -# gem: --no-document diff --git a/beetag b/beetag index e6b9864..c0d7ff6 100755 --- a/beetag +++ b/beetag @@ -60,7 +60,7 @@ beetag-help() { cat <<'EOF' -y other genres z fg player ' = toggle play 1-5 rate ] repeat1 +y other genres z fg player ' = toggle autoplay 1-5 rate ] repeat1 ; previous ) delete j/k skip mpv_keys vol,pause,seek EOF hr @@ -365,14 +365,18 @@ usage: beetag [OPTIONS] QUERY It lists/plays the query, reads an input char for tagging one by one. -note, you may want to change the play command for doing rapid taging +note: you may want to change the play command for doing rapid taging by immediately jumping forward into the song. this is set in the beets config yaml. -(available buttons: ` _ ] [ and non-printing chars, see +available buttons: + * ` _ ] [ + * ' (autoplay), I've never used it so it could just be a cli option. + * non-printing chars, see https://stackoverflow.com/questions/10679188/casing-arrow-keys-in-bash + note: after foregrounding the player, must quit it to get back. can't ctrl-c. keys I dont need help to remember: @@ -392,7 +396,7 @@ beetag() { source /a/bin/ds/beet-data # state vars altered by user input: - local char do_rare_genres last_genre_i doplay=true repeat1=false + local char do_rare_genres last_genre_i autoplay=true repeat1=false local -i volume=70 read_wait=2 j=0 local -a button_map local -A button_i @@ -517,7 +521,7 @@ beetag() { beetag-help printf "██ %s\n" "$ls_out" beetag-nostatus 1 - if $doplay; then + if $autoplay; then if $first_play; then first_play=false; mpvrpc-wait-idle; fi mpvrpc-loadfile "$path" erasable_line=false @@ -528,7 +532,7 @@ beetag() { while true; do char= - if $doplay; then + if $autoplay; then ret=0 read -rsN1 -t $read_wait char || ret=$? read_wait=2 @@ -561,11 +565,11 @@ beetag() { break ;; "'") - if $doplay; then - echo "play toggled off" - doplay=false + if $autoplay; then + echo "autoplay toggled off" + autoplay=false else - doplay=true + autoplay=true mpvrpc-loadfile "$path" erasable_line=false fi diff --git a/brc b/brc index 3043c2e..545aa85 100644 --- a/brc +++ b/brc @@ -4647,6 +4647,19 @@ wgkey() { umask $umask_orig } +# Dedupe a project with several node_modules dirs for the purpose of +# license scanning. Dedupe is by directory name, not worried about +# versions for a simple license scan. +dedup-node-modules() { + mkdir -p ../deduped + for d in $(find . -type d -name node_modules | perl -e 'print sort {length $b <=> length $a} <>'); do for mod in $d/*; do [[ -d $mod ]] || rm $mod; n="${m##*/}"; if [[ -d ../deduped/$n ]]; then rm -r $mod; else mv $mod ../deduped; fi; done; done + cd ../deduped + # for each dir that has a min.js file, compare char count of min.js + # files vs char count of files with just .js or .ts, etc. If minified + # is bigger, then flag it by doing an ls. + for d in $(find -type f -name '*.min.js'|sed -r 's,^./,,;s,/.*$,,' | sort -u); do a=$(cat $(find $d -name '*.min.js')|wc -c); b=$(cat $(find $d -type f \! -name '*.min.js' \( -name '*.js' -o -name '*.ts' -o -name '*.mjs' -o -name '*.tsx' -o -name '*.cts' -o -name '*.mts \)') | wc -c); if ! uintp "$a" "$b"; then e "uint $a, $b"; continue; fi; if (( a < b )); then find $d -name '*.min.js' -delete; else m ll $d; fi; done + #time /t/sc/scancode --info --classify --only-findings --max-in-memory 300000 -clpue --unknown-licenses --tallies --tallies-with-details --summary --generated --json-pp scan.json . + } # * stuff that makes sense to be at the end diff --git a/brc2 b/brc2 index 998f280..e36cef2 100644 --- a/brc2 +++ b/brc2 @@ -106,6 +106,13 @@ if [[ $EUID == 1000 ]]; then # shellcheck disable=SC1091 # may not exist, & third party [[ -s "$NVM_DIR/bash_completion" ]] && source "$NVM_DIR/bash_completion" # This loads nvm bash_completion } + # the nvm docs say: to update, rerun the curl|bash install + # script. Then later it says "the install script basically just clones + # the repo", wow, what a horribly gratuitous use of curl|bash. + nvm-update() { + cd ~/.nvm + git pull + } fi export I2X_SORT_ORDER=path_desc @@ -683,26 +690,6 @@ beetadd() { unset -f err-cleanup } -# beetag: error: no result from beet ls totag:t -# [1] 711197 -# █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ -# a arp i nv s sleep 8 pump1 -# b avant l latin t techno , pumprap -# c blues m metal u world . rend -# d chill n mq v expl / run -# e country o pop w gimicky - tiredof -# f dance p rap 6 sad = worm -# g darkwave r rock 7 love \ lesser_version -# h hardcore - -# y other genres z fg player ' = toggle play 1-5 rate ] repeat1 -# ; previous _ delete j/k skip mpv_keys vol,pause,seek -# █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ -# ██ -# [file] Cannot open file '': No such file or directory -# Failed to open . -# bash: ( j + 1 ) % id_count : division by 0 (error token is "id_count ") - ##### begin beet2nav functions ##### # update navidrome music data after doing beets tagging diff --git a/fsf-script-lib b/fsf-script-lib index d24e751..1abab5f 100644 --- a/fsf-script-lib +++ b/fsf-script-lib @@ -54,6 +54,13 @@ uint_regex='^[0-9]+$' # shellcheck disable=SC2034 graph_regex='^[[:graph:]]+$' +# slightly less typing +uintp() { + for arg; do + [[ $arg =~ $uint_regex ]] || return 1 + done +} + # horizontal row. used to break up output # shellcheck disable=SC2120 # not a big deal. hr() { -- 2.30.2