From: Ian Kelling Date: Sat, 1 Feb 2025 04:12:25 +0000 (-0500) Subject: cleanup environment variables X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=072f39af768970e5548f0c4bc19eff76f7aba0bf;p=distro-setup cleanup environment variables --- diff --git a/beet-data b/beet-data index 0aee2b4..52c1256 100644 --- 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 355edb2..9c54ab9 100644 --- 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 47d71c7..c55eca9 100644 --- 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. diff --git a/filesystem/etc/profile.d/environment.sh b/filesystem/etc/profile.d/environment.sh index d91252c..31d55bb 100644 --- a/filesystem/etc/profile.d/environment.sh +++ b/filesystem/etc/profile.d/environment.sh @@ -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