cleanup environment variables
authorIan Kelling <ian@iankelling.org>
Sat, 1 Feb 2025 04:12:25 +0000 (23:12 -0500)
committerIan Kelling <ian@iankelling.org>
Sat, 1 Feb 2025 04:12:25 +0000 (23:12 -0500)
beet-data
brc
brc2
filesystem/etc/profile.d/environment.sh

index 0aee2b4d9577e061ee861799758860f0e18d4701..52c1256fc06bcdd5f075212b996576e32d6d9beb 100644 (file)
--- a/beet-data
+++ b/beet-data
@@ -226,4 +226,5 @@ _beet-gen-global-vars() {
     beetapl $t $t:t
   done
 }
-_beet-gen-global-vars
+
+beet-gen-global-vars
diff --git a/brc b/brc
index 355edb22d3f907be8d50df57c4cdba6bf889b48c..9c54ab924e473b62151cde645e92540f1f91d96e 100644 (file)
--- a/brc
+++ b/brc
@@ -1028,13 +1028,15 @@ cbs() {
 }
 
 # a1 = awk {print $1}
-for field in {1..20}; do
-  eval a$field"() { awk '{print \$$field}'; }"
+for _field in {1..20}; do
+  eval a$_field"() { awk '{print \$$_field}'; }"
 done
+unset _field
 # h1 = head -n1
-for num in {1..9}; do
-  eval h$num"() { head -n$num || [[ \$? == 141 ]]; }"
+for _num in {1..9}; do
+  eval h$_num"() { head -n$_num || [[ \$? == 141 ]]; }"
 done
+unset _num
 
 
 hexipv4() {
@@ -3850,6 +3852,7 @@ if [[ $- == *i* ]]; then
   # so I've thrown a bunch of things at the wall to speed it up.
   prompt-command() {
     local return=$? # this MUST COME FIRST
+    local jobs_char
 
     PS1='\w'
     if [[ $SSH_CLIENT ]]; then
@@ -3923,7 +3926,6 @@ if [[ $- == *i* ]]; then
     if [[ $MAIL_HOST && $MAIL_HOST != "$HOSTNAME" ]]; then
       ps_char="@ $ps_char"
     fi
-    jobs_char=
     if [[ $(jobs -p) ]]; then
       jobs_char='j\j '
     fi
@@ -3972,7 +3974,7 @@ if [[ $- == *i* ]]; then
     # version 211203 does not have this feature, 230805 does.  we can't
     # detect this over ssh. We could copy the var over ssh, but I'd
     # rather just wait until i'm not running the earlier konsole.
-    if [[ $TYPESCRIPT_SHELL != true && $TERM == xterm-256color && $KONSOLE_VERSION && ! $KONSOLE_VERSION == 2[01]* ]]; then
+    if [[ $BASH_COMMAND != set && $TYPESCRIPT_SHELL != true && $TERM == xterm-256color && $KONSOLE_VERSION && ! $KONSOLE_VERSION == 2[01]* ]]; then
       # This is from konsole, copied after pressing ctrl-alt-] .
       # I figured out what it does from reading
       # https://gitlab.freedesktop.org/Per_Bothner/specifications/proposals/semantic-prompts.md
@@ -4003,8 +4005,8 @@ if [[ $- == *i* ]]; then
         PS2='\[\e]133;A\a\]'"$PS2"'\[\e]133;B\a\]'
       fi
     fi
-
   }
+
   PROMPT_COMMAND=(prompt-command)
 
   if [[ $TERM == screen* ]]; then
diff --git a/brc2 b/brc2
index 47d71c75dac8b97faf85df34b90aac27f81a3a3a..c55eca9627d6602767add013f36e8eff8975d613 100644 (file)
--- a/brc2
+++ b/brc2
@@ -76,9 +76,6 @@ case $HOSTNAME in
 esac
 
 
-export WCDHOME=/a
-
-
 case $EUID in
   0)
     # shellcheck disable=SC2034 # used in brc
@@ -117,7 +114,6 @@ else
   export NOT_MAIL_HOST_P=t
 fi
 
-source /a/bin/ds/beet-data
 
 
 # * functions
@@ -570,6 +566,7 @@ _iki-convert() {
 # for going in the reverse direction, run
 # /b/ds/navidrome-playlist-export
 beetsmartplaylists() {
+  source /a/bin/ds/beet-data
   install -m 0700 -d /tmp/ianbeetstmp
   beet splupdate
   # kill off any playlists we deleted. they will still need manual
@@ -623,6 +620,7 @@ update annotation set rating = $rating
 
 # Export beets ratings into navidrome
 beetrating() {
+  source /a/bin/ds/beet-data
   local ssh_prefix
   source /p/c/domain-info
   if [[ $HOSTNAME != "$d_host" ]]; then
@@ -634,6 +632,7 @@ beetrating() {
 
 # Do transcoding and hardlinking of audio files for navidrome.
 beetconvert() {
+  source /a/bin/ds/beet-data
   local tmpf
   tmpf="$(mktemp)"
   # a bunch of effort to ignore output we dont care about...
@@ -641,9 +640,11 @@ beetconvert() {
   beet -c $tmpf convert -y $nav_convert_query > >(grep -vFx 'ignore_this' ||:) 2> >(grep -v '^convert: Skipping' ||:)
   rm "$tmpf"
 }
+
 # This deletes files in the converted directory which should no longer
 # be there due to a rename of the unconverted file.
 beetconvert-rm-extras() {
+  source /a/bin/ds/beet-data
   local l tmpf
   local -A paths
   tmpf="$(mktemp)"
@@ -670,6 +671,7 @@ beetconvert-rm-extras() {
 }
 
 beets-gen-playlists() {
+  source /a/bin/ds/beet-data
   local i str
   local -a query_array query_str
   for i in "${!bpla[@]}"; do
@@ -687,6 +689,7 @@ EOF
 
 # beet playlist. use beetag with a playlist name
 bpl() {
+  source /a/bin/ds/beet-data
   local playlist playlist_regex
   case $1 in
     -h|--help)
@@ -711,6 +714,7 @@ complete -W "${!bpla[*]}" bpl
 
 # beet modify quietly
 beetmq() {
+  source /a/bin/ds/beet-data
   local tmpf
   tmpf="$(mktemp)"
   # a bunch of effort to ignore output we dont care about...
@@ -735,6 +739,7 @@ dv() {
 
 # Must be called from beetag for variables to be setup
 beetag-help() {
+  source /a/bin/ds/beet-data
   local -i i j col_total row col button_total row_total remainder_cols remainder_term
   col_total=4
   button_total=${#button_map[@]}
@@ -889,6 +894,7 @@ mpvrpc-loadfile() {
 #
 # todo: enter should also unpause
 beetag()  {
+  source /a/bin/ds/beet-data
   local last_genre_i fstring tag id char new_item char_i genre tag remove doplay i j random path
   local do_rare_genres read_wait line lsout tmp ls_line skip_lookback
   local escape_char escaped_input expected_input skip_input_regex right_pad erasable_line seek_sec
@@ -1344,6 +1350,7 @@ beetadd() {
 
 # update navidrome music data after doing beets tagging
 beet2nav() {
+  source /a/bin/ds/beet-data
   m beetpull
   m beetconvert
   m beetrating
@@ -1356,6 +1363,7 @@ beet2nav() {
 
 # pull in beets library locally
 beetpull() {
+  source /a/bin/ds/beet-data
   local sshfs_host sshfs_cmd
   sshfs_host=b8.nz
   source /p/c/domain-info
@@ -1375,6 +1383,7 @@ beetpull() {
 # remove all playlists in navidrome, for when I make big
 # playlist name changes and just want to scrap everything.
 nav-rm-plists() {
+  source /a/bin/ds/beet-data
   local tmpf id
   tmpf=$(mktemp)
   source /p/c/domain-info
@@ -1406,6 +1415,7 @@ er() {
 # "artist:" it is used as the artist instead of each artist in QUERY.
 #
 beegenre() {
+  source /a/bin/ds/beet-data
   local count artist artregex genre singleartist tmpf tmpf2
   local -a artists genres
   singleartist=false
@@ -2092,80 +2102,84 @@ batp() {
   cat /sys/class/power_supply/BAT0/capacity
 }
 
-# List of apps to install/update
-# Create from existing manually installed apps by doing
-# fdroidcl update
-# fdroidcl search -i, then manually removing
-# automatically installed/preinstalled apps
-
-#
-# # my attempt at recovering from boot loop:
-# # in that case, boot to recovery (volume up, home button, power, let go of power after samsun logo)
-# # then
-# mount /dev/block/mmcblk0p12 /data
-# cd /data
-# find -iname '*appname*'
-# rm -rf FOUND_DIRS
-# usually good enough to just rm -rf /data/app/APPNAME
-#
-# currently broken:
-# # causes replicant to crash
-# org.quantumbadger.redreader
-# org.kde.kdeconnect_tp
-
-# not broke, but wont work without gps
-#com.zoffcc.applications.zanavi
-# not broke, but not using atm
-#com.nutomic.syncthingandroid
-# # doesn\'t work on replicant
-#net.sourceforge.opencamera
-#
-fdroid_pkgs=(
-  net.mullvad.mullvadvpn
-  org.schabi.newpipe
-  io.github.subhamtyagi.lastlauncher
-  io.anuke.mindustry
-  com.biglybt.android.client
-  de.marmaro.krt.ffupdater
-  me.ccrama.redditslide
-  org.fedorahosted.freeotp
-  at.bitfire.davdroid
-  com.alaskalinuxuser.justnotes
-  com.artifex.mupdf.viewer.app
-  com.danielkim.soundrecorder
-  com.fsck.k9
-  com.ichi2.anki
-  com.jmstudios.redmoon
-  com.jmstudios.chibe
-  org.kde.kdeconnect_tp
-  com.notecryptpro
-  com.termux
-  cz.martykan.forecastie
-  de.danoeh.antennapod
-  de.blinkt.openvpn
-  de.marmaro.krt.ffupdater
-  eu.siacs.conversations
-  free.rm.skytube.oss
-  im.vector.alpha # riot
-  info.papdt.blackblub
-  me.tripsit.tripmobile
-  net.gaast.giggity
-  net.minetest.minetest
-  net.osmand.plus
-  org.isoron.uhabits
-  org.linphone
-  org.gnu.icecat
-  org.smssecure.smssecure
-  org.yaaic
-  sh.ftp.rocketninelabs.meditationassistant.opensource
-)
-# https://forum.xda-developers.com/android/software-hacking/wip-selinux-capable-superuser-t3216394
-# for maru,
-#me.phh.superuser
 
 fdup() {
   local -A installed updated
   local p
+  local -a fdroid_pkgs
+
+  # List of apps to install/update
+  # Create from existing manually installed apps by doing
+  # fdroidcl update
+  # fdroidcl search -i, then manually removing
+  # automatically installed/preinstalled apps
+
+  #
+  # # my attempt at recovering from boot loop:
+  # # in that case, boot to recovery (volume up, home button, power, let go of power after samsun logo)
+  # # then
+  # mount /dev/block/mmcblk0p12 /data
+  # cd /data
+  # find -iname '*appname*'
+  # rm -rf FOUND_DIRS
+  # usually good enough to just rm -rf /data/app/APPNAME
+  #
+  # currently broken:
+  # # causes replicant to crash
+  # org.quantumbadger.redreader
+  # org.kde.kdeconnect_tp
+
+  # not broke, but wont work without gps
+  #com.zoffcc.applications.zanavi
+  # not broke, but not using atm
+  #com.nutomic.syncthingandroid
+  # # doesn\'t work on replicant
+  #net.sourceforge.opencamera
+  #
+  fdroid_pkgs=(
+    net.mullvad.mullvadvpn
+    org.schabi.newpipe
+    io.github.subhamtyagi.lastlauncher
+    io.anuke.mindustry
+    com.biglybt.android.client
+    de.marmaro.krt.ffupdater
+    me.ccrama.redditslide
+    org.fedorahosted.freeotp
+    at.bitfire.davdroid
+    com.alaskalinuxuser.justnotes
+    com.artifex.mupdf.viewer.app
+    com.danielkim.soundrecorder
+    com.fsck.k9
+    com.ichi2.anki
+    com.jmstudios.redmoon
+    com.jmstudios.chibe
+    org.kde.kdeconnect_tp
+    com.notecryptpro
+    com.termux
+    cz.martykan.forecastie
+    de.danoeh.antennapod
+    de.blinkt.openvpn
+    de.marmaro.krt.ffupdater
+    eu.siacs.conversations
+    free.rm.skytube.oss
+    im.vector.alpha # riot
+    info.papdt.blackblub
+    me.tripsit.tripmobile
+    net.gaast.giggity
+    net.minetest.minetest
+    net.osmand.plus
+    org.isoron.uhabits
+    org.linphone
+    org.gnu.icecat
+    org.smssecure.smssecure
+    org.yaaic
+    sh.ftp.rocketninelabs.meditationassistant.opensource
+  )
+  # https://forum.xda-developers.com/android/software-hacking/wip-selinux-capable-superuser-t3216394
+  # for maru,
+  #me.phh.superuser
+
+
   # tried putting this in go buildscript cronjob,
   # but it failed with undefined: os.UserCacheDir. I expect its due to
   # an environment variable missing, but its easier just to stick it here.
index d91252c6b156cd5b27a49a11f682f2737bddd84d..31d55bb182f6d654ec4cc3a4775570f77b050370 100644 (file)
@@ -15,9 +15,7 @@ if [ -f $HOME/path-add-function ]; then
 
 
   # ~/.local is newer, eg ruby 3.0+
-  for p in $HOME/.gem/ruby/*/bin $HOME/.local/share/gem/ruby/*/bin; do
-    path-add --ifexists --end $p
-  done
+  path-add --ifexists --end $HOME/.gem/ruby/*/bin $HOME/.local/share/gem/ruby/*/bin
 
   if [ -r /etc/alternatives/java_sdk ]; then
     export JAVA_HOME=/etc/alternatives/java_sdk