echo "$line_int | ${ls_lines[i]}"
line_int+=1
done
- } | less -F
+ # returns 141 if you hit q before going to the end.
+ } | less -F || [[ $? == 141 ]]
beetag-track-select
if $got_track; then
break
CDPATH=.
-
# remove all aliases. aliases provided by the system tend to get in the way,
# for example, error happens if I try to define a function the same name as an alias
unalias -a
# perhaps its fixed in newer git version, which fails to make for me
# this note is from 6-2014.
# still broken in flidas.
-#shopt -s nullglob
+# Giving it a shot in 2025 again!
+shopt -s nullglob
# make tab on an empty line do nothing
shopt -s no_empty_cmd_completion
# enable **
shopt -s globstar
-
# inside emacs fixes
if [[ $LC_INSIDE_EMACS ]]; then
# EMACS is used by bash on startup, but we dont need it anymore.
# * include files
-if [[ -s $bashrc_dir/path-add-function ]]; then
- source $bashrc_dir/path-add-function
+if [[ -s $bashrc_dir/path_add-function ]]; then
+ source $bashrc_dir/path_add-function
if [[ $SSH_CLIENT ]]; then
- path-add $bashrc_dir
+ path_add $bashrc_dir
fi
fi
fi
# go exists here
-path-add --ifexists /usr/local/go/bin
+path_add --ifexists /usr/local/go/bin
# Wrap source command to look in alternate directory in conjunction with
# sl().
shellcheck-except() {
local quotes others
quotes=2048,2064,2068,2086,2119,2206,2254,2231
- others=2029,2032,2033,2054,2164,2317
+ others=2029,2032,2033,2054,2164,2190,2317
shellcheck -e $quotes,$others "$@" || return $?
}
# wrapper for shellcheck with better defaults.
# see https://savannah.gnu.org/maintenance/fsf/bash-style-guide/ for justifications
local quotes others
local -i ret=0
- quotes=2048,2064,2068,2086,2119,2206,2254,2231
- others=2029,2032,2033,2054,2164,2317
shellcheck-except -ax -W 999 "$@" || ret=$?
if (( ret >= 1 )); then
echo "A template comment to disable is now in clipboard. eg: # shellcheck disable=SC2206 # reason"
# did work in 5.1 something. It did not work in emacs. And, one time
# it just randomly output to the terminal. Not worth it.
- unset IFS
-
if [[ $HISTFILE ]]; then
# save history. if our filesystem went read-only or something, continue on
history -a ||:
# * stuff that makes sense to be at the end
-
-# best practice
-unset IFS
+# note, if we unset IFS, that will mess up completion scripts which
+# maybe try to set it back to its original value and don't have the
+# logic for unsetting it.
if [[ -s "$HOME/.rvm/scripts/rvm" ]]; then
# shellcheck disable=SC1091
}
-source /a/bin/distro-setup/path-add-function
-path-add /a/exe
+source /a/bin/distro-setup/path_add-function
+path_add /a/exe
# add this with absolute paths as needed for better security
-#path-add --end /path/to/node_modules/.bin
+#path_add --end /path/to/node_modules/.bin
## for yarn, etc
-#path-add --end /usr/lib/node_modules/corepack/shims/
+#path_add --end /usr/lib/node_modules/corepack/shims/
# pip3 --user things go here:
-path-add --end ~/.local/bin
-path-add --ifexists --end /a/work/libremanage
-path-add --ifexists --end /a/opt/adt-bundle*/tools /a/opt/adt-bundle*/platform-tools
-path-add --ifexists --end /a/opt/scancode-toolkit-3.10.
-path-add --ifexists --end /p/bin
+path_add --end ~/.local/bin
+path_add --ifexists --end /a/work/libremanage
+path_add --ifexists --end /a/opt/adt-bundle*/tools /a/opt/adt-bundle*/platform-tools
+path_add --ifexists --end /a/opt/scancode-toolkit-3.10.
+path_add --ifexists --end /p/bin
case $HOSTNAME in
sy|bo)
fi
beet import --set totag=t $single_track_arg $genre_arg $rating_arg "$import_path"
function err-cleanup() {
+ # If we run `beet import --set`, and import an album, the set works
+ # at the album level and the track level. Removing from album is
+ # supposed to remove from tracks too, but of course we have imported
+ # non-album tracks. Note, it seems we can just ignore album level
+ # tags for things like rating and genre that aren't smart tags.
if beet ls -a totag:t | grep -q .; then
beet modify -ay totag:t 'totag!'
fi
nav_convert_query="^genre:spoken-w ^genre:skit ^lesser_version:t rating:3..5"
-# Export beets ratings into navidrome
-beetrating() {
- local ssh_prefix
- source /p/c/domain-info
- if [[ $HOSTNAME != "$d_host" ]]; then
- ssh_prefix="ssh b8.nz"
- fi
- # shellcheck disable=SC2016 # obvious reason
- beet ls -f '$rating $path' $nav_convert_query | $ssh_prefix beetrating-stdin
-}
-
# This deletes files in the converted directory which should no longer
# be there due to a rename of the unconverted file.
rmdir /tmp/ianbeetstmp
}
+# Export beets ratings into navidrome
+beetrating() {
+ local ssh_prefix
+ source /p/c/domain-info
+ if [[ $HOSTNAME != "$d_host" ]]; then
+ ssh_prefix="ssh b8.nz"
+ fi
+ # shellcheck disable=SC2016 # obvious reason
+ beet ls -f '$rating $path' $nav_convert_query | $ssh_prefix beetrating-stdin
+}
+
# internal function for beetrating, in case we need to ssh
beetrating-stdin() {
local tmp rating path cpath sqlpath userid
# limitations under the License.
EOF
+}
+
+apache-header-fsf() {
+ # First paragraph is to avoid people being confused about why a
+ # file is apache licensed.
+ cat <<'EOF'
+# FSF follows the GNU license recommendations at
+# https://www.gnu.org/licenses/license-recommendations.en.html. They
+# recommend that small programs, < 300 lines, be licensed under the
+# Apache License 2.0. This file contains or is part of one or more small
+# programs. If a small program grows beyond 300 lines, FSF will likely
+# change to change its license to a recommended GPL license.
+
+# Copyright 2025 Free Software Foundation
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+# http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+EOF
}
+
# apply apache to git tracked bash files + README, except files with A?GPL3 header.
apache-apply-repo() {
for f in $(git ls-files); do
}
apache-apply() {
+ local header_suffix
+ if [[ $1 == -* ]]; then
+ header_suffix="$1"
+ shift
+ fi
for file; do
if [[ ! -e $file ]]; then
echo '#!/bin/bash' >$file
if head -n1 "$file"| grep -E '^#!/' &>/dev/null; then
{
head -n1 "$file"
- apache-header
+ apache-header$header_suffix
tail -n+2 "$file"
} | sponge "$file"
else
{
- apache-header
+ apache-header$header_suffix
cat "$file"
} | sponge "$file"
fi
done
}
+apache-fsf() {
+ apache-apply -fsf "$@"
+}
+
# strip out the apache license from a file.
apache-strip() {
# shellcheck disable=SC2044 # meh
}
pfind() { #find *$1* in $PATH
- [[ $# != 1 ]] && { echo requires 1 argument; return 1; }
+ if [[ $# != 1 ]]; then echo requires 1 argument; return 1; fi
local pathArray
- IFS=: pathArray=($PATH); unset IFS
+ IFS=: pathArray=($PATH)
find "${pathArray[@]}" -iname "*$1*"
}
break
fi
done
- paths="/p/c /p/profanity-config /b/bash_unpublished"
+ paths="/p/c/ /p/profanity-config/ /b/bash_unpublished/ /c/ /f/s/fsf/ /f/backup-scripts/ /f/gluestick/"
find $paths -not \( -name .svn -prune -o -name .git -prune \
-o -name .hg -prune -o -name .editor-backups -prune \
-o -name .undo-tree-history -prune \) 2>/dev/null | grep -iP --color=auto -- "$*" ||:
# They want to be added to the start, but i think
# that should be avoided unless we really need it.
-path-add --end ~/.npm-global
+path_add --ifexists --end ~/.npm-global
-path-add --end $HOME/.cargo/bin
+path_add --end $HOME/.cargo/bin
if type -P rg &>/dev/null; then
# --no-messages because of annoying errors on broken symlinks
}
# taken from default changes to bashrc and bash_profile
-path-add --end --ifexists $HOME/.rvm/bin
+path_add --end --ifexists $HOME/.rvm/bin
# also had ruby bin dir, but moved that to environment.sh
# so its included in overall env
# fi
-# best practice
-unset IFS
-
# https://wiki.archlinux.org/index.php/Xinitrc#Autostart_X_at_login
# i added an extra condition as gentoo xorg guide says depending on
# $DISPLAY is fragile.
# pressing tab after sdf here:
# scp sdfbash: set +o noglob: command not found
# in t11, bash 5.1.16. this fixes it.
-sudo sed -ri 's/([[:space:]]*)(\$reset)$/\1set +o noglob #$reset/' /usr/share/bash-completion/bash_completion
+sudo sed -ri 's/^([[:space:]]*)(\$reset)$/\1set +o noglob #$reset/' /usr/share/bash-completion/bash_completion
rm -fv /home/iank/.mpv/watch_later
rm -rf /home/iank/.mpv
--- /dev/null
+#!/bin/bash
+#
+# Config file for Kaya, a restic backup wrapper
+#
+# This will be sourced by bash & systemd EnvironmentFile
+
+#backup_root=/srv/backups/kaya
+#backup_root=/backup/kaya
+backup_root=/mnt/r2/fsf/kaya
+
+# set if using non-default port as in 'rest-server --listen :PORT'
+# local_port=8000
+remote_port=8777 # some aribtrary port
# Exports here get inherited by X, that is the only reason to do things
# here. However, they do not get sent with sl().
-if [ -f $HOME/path-add-function ]; then
- . $HOME/path-add-function
- path-add /usr/sbin /usr/local/sbin /a/exe /a/opt/bin
+if [ -f $HOME/path_add-function ]; then
+ . $HOME/path_add-function
+ path_add /usr/sbin /usr/local/sbin /a/exe /a/opt/bin
# if usr merge, dont need it
if [[ ! -L /sbin ]]; then
- path-add /sbin
+ path_add /sbin
fi
- path-add --end $HOME/.cabal/bin
- path-add --end /snap/bin
+ path_add --ifexists --end $HOME/.cabal/bin
+ path_add --end /snap/bin
# ~/.local is newer, eg ruby 3.0+
- path-add --ifexists --end $HOME/.gem/ruby/*/bin $HOME/.local/share/gem/ruby/*/bin
+ 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
- path-add /etc/alternatives/java_sdk
+ path_add /etc/alternatives/java_sdk
fi
export GUIX_PROFILE=/root/.config/guix/current
if [ -f $GUIX_PROFILE/etc/profile ]; then
. $GUIX_PROFILE/etc/profile
fi
- path-add $HOME/.guix-profile/bin
+ path_add --ifexists $HOME/.guix-profile/bin
export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
fi
# -L resolve links
rsync --exclude=/h --exclude=/h.pub \
--exclude=/hrsa --exclude=/hrsa.pub \
- --exclude /config --exclude /confighome -rtL --delete $user_ssh_dir/ /root/.ssh
+ --exclude /config --exclude /confighome --exclude=/work -rtL --delete $user_ssh_dir/ /root/.ssh
+# copy of work key with no pass for kaya.
+rsync -a /q/root/work /root/.ssh
if [[ -e /q/root/h ]]; then
cp -a /q/root/{h,hrsa}{,.pub} /root/.ssh
fi
mp_args="-m /o,/a,/q,/qd,/qr"
check_installed=false
orig_args=("$@")
-if ! temp=$(getopt -l check-installed,force,pull-reexec,help afioh "$@"); then
+if ! temp=$(getopt -l check-installed,force,pull-reexec,help 2afioh "$@"); then
err "args invalid. args=$*"
fi
eval set -- "$temp"
while true; do
case $1 in
+ -2)
+ host2_only=true
+ ;;
-a) snapshot_arg=resume ;;
--force|-f)
force=true
direction=$1
host=$2
-case $script_name in
- switch-mail-host)
- if [[ $MAIL_HOST != "$HOST2" ]]; then
- mail_only=true
- fi
- ;;
- switch-host2)
- host2_only=true
- ;;
- *)
- err unexpected script name
- ;;
-esac
+if ! $host2_only && [[ $MAIL_HOST != "$HOST2" ]]; then
+ mail_only=true
+fi
if $mail_only; then
mp_args="-m /o"
# avoiding bashisms so it can be used in edge cases where I don't have bash,
# however, I'm not super confident that I've avoided them all
-#
-path-add() {
+path_add() {
local help="usage: path_add [options] PATH...
--help: print this
--end: adds to end of path, which will give it lowest priority
if ! test "$1"; then
return 0
fi
+ ifs="$IFS"
IFS=:
# build up the path without the components we want to add
for y in $PATH; do
fi
done
- unset IFS
+ IFS="$ifs"
PATH="$newpath"
for x in "$@"; do
if ! $ifexists || [ -d "$x" ]; then
+++ /dev/null
-../../path-add-function
\ No newline at end of file
--- /dev/null
+../../path_add-function
\ No newline at end of file