# so this can set extdebug and avoid the bash debugger.
-if [[ -s /a/bin/errhandle/err ]]; then
- # shellcheck source=/a/bin/errhandle/err
- source /a/bin/errhandle/err
+if [[ -s /a/bin/bash-bear-trap/bash-bear ]]; then
+ # shellcheck source=/a/bin/bash-bear-trap/bash-bear
+ source /a/bin/bash-bear-trap/bash-bear
# wtf, shellcheck doesn't allow disabling warnings in elifs
else
# bleh shellcheck can't handle disabling in an elif, so nesting this if.
# shellcheck disable=SC2154 # set in .bashrc
if [[ -s $bashrc_dir/err ]]; then
- # shellcheck source=/a/bin/errhandle/err
+ # shellcheck source=/a/bin/bash-bear-trap/bash-bear
source $bashrc_dir/err
fi
fi
# bash: /usr/share/bashdb/bashdb-main.inc: No such file or directory
# bash: warning: cannot start debugger; debugging mode disabled
if [[ $SOE ]]; then
- if [[ -e /a/bin/errhandle/err ]]; then
- source /a/bin/errhandle/err
+ if [[ -e /a/bin/bash-bear-trap/bash-bear ]]; then
+ source /a/bin/bash-bear-trap/bash-bear
fi
fi
fi
done
}
+# like running cl <enter> a <enter>
+cla() {
+ local line
+ mapfile -t lines <~/.cdirs
+ start=$(( ${#lines[@]} - 1 ))
+ for (( j=start; j >= 0; j-- )); do
+ line="${lines[$j]}"
+ if [[ ! $line || ! -d "$line" || $line == "$PWD" || line == "$HOME" ]]; then
+ continue
+ fi
+ e "$line"
+ c "$line"
+ break
+ done
+}
## END functions to change directory better than cd ##
# pee do. run args as a command with output copied to syslog.
caf() {
local file
-find -L "$@" -type f -not \( -name .svn -prune -o -name .git -prune \
+ find -L "$@" -type f -not \( -name .svn -prune -o -name .git -prune \
-o -name .hg -prune -o -name .editor-backups -prune \
-o -name .undo-tree-history -prune \) -printf '%h\0%d\0%p\n' | sort -t '\0' -n \
- | awk -F '\0' '{print $3}' 2>/dev/null | while read -r file; do
+ | awk -F '\0' '{print $3}' 2>/dev/null | while read -r file; do
hr
printf "%s\n" "$file"
hr
cat "$file"
-done
+ done
}
ccomp cat cf caf
cx() {
chmod +X "$@"
- }
+}
cam() {
git commit -am "$*"
fi
}
+# g pipe. like: cmd | emacs. save cmd output to tmp file, then edit.
+gp() {
+ cat &>/a/tmp/gtmp
+ g "$@" /a/tmp/gtmp
+ }
+
+# like cmd &> tempfile; emacs tempfile
+gc() {
+ "$@" &> /a/tmp/gtmp
+ g /a/tmp/gtmp
+ }
+
# force terminal version
gn() {
g -n "$@"
sed -i --follow-symlinks "$@"
}
+
+
rmstrips() {
ssh fencepost head -n 300 /gd/gnuorg/EventAndTravelInfo/rms-current-trips.txt | less
}
# Convert brains file path to url and vice versa
# usage: brains [URL_OR_PATH]
brains() {
- _iki-convert '(/a)?/f/brains' brains.fsf.org/wiki "$@"
+ _iki-convert brains.fsf.org/wiki "$@"
}
glue() {
- _iki-convert '(/a)?/f/gluestick' gluestick.office.fsf.org "$@"
+ _iki-convert gluestick.office.fsf.org "$@"
}
-# usage: $0 REPO_PATH [URL_OR_PATH]
+# usage: see above
_iki-convert() {
- local url prefix path input err repo_dir dir url_dir url
- repo_dir="$1"
- prefix="$2"
- shift 2
- err=false
- if $err; then
- return 1
- fi
+ local url url_prefix path input err repo_dir dir url_dir url name
+ url_prefix="$1"
+ name="${url_prefix%%.*}"
+ repo_dir="/f/$name"
+ shift
if [[ $1 ]]; then
input="$*"
else
fi
case $input in
http*)
- path="$repo_dir/${input##http*://"$prefix"/}"
+ path="$repo_dir/${input##http*://"$url_prefix"/}"
if [[ $path == */ ]]; then
path=${path%/}.mdwn
fi
;;
*)
path=$(fp "$input")
- url_dir=$(echo "$path" | sed -r "s,^$repo_dir/,,")
- url="https://$prefix/$url_dir"
+ url_dir=$(echo "$path" | sed -r "s,^(/a)?$repo_dir/,,")
+ url="https://$url_prefix/$url_dir"
url="${url%.mdwn}/"
j echo "$url"
;;
# q quit
# ret next
#
-beetag() {
+beetag() {
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 help line lsout tmp ls_line skip_lookback
local escape_char escaped_input expected_input skip_input_regex right_pad erasable_line seek_sec
done
}
+prof-sort() {
+ case $HOSTNAME in
+ kd)
+ prof-recent-sort
+ ;;
+ *)
+ ssh b8.nz prof-recent-sort
+ ;;
+ esac
+}
+
+prof-recent-sort() {
+ local d dates date files f
+ # consider making the day count passed by parameter. note: this works: $(date -d '2 day ago' +%Y_%m_%d)
+ dates=("$(date +%Y_%m_%d)" "$(date -d '1 day ago' +%Y_%m_%d)" )
+ files=()
+ for d in /d/p/profanity/chatlogs/iank_at_fsf.org/!(rooms); do
+ for date in ${dates[@]}; do
+ f=$d/$date.log
+ if [[ -e $f ]]; then
+ files+=($f)
+ fi
+ done
+ done
+ for f in "${files[@]}"; do
+ sed "s/\$/ $f/" $f
+ done | sort
+}
+
# usage: debvm DEBIAN_VERSION RAM_MB
debvm() {
# rg with respecting vcs ignore files
rgv() {
ret=0
+ # settings that are turned off for pipes, keep them on.
+ # Found by searching for "terminal" in --help
+ # --heading
+ # -n
+ #
# -. = search dotfiles
# -z = search zipped files
# -i = case insensitive
# -M = max columns
# --no-messages because of annoying errors on broken symlinks
# --no-ignore-parent because i have /a/.git which ignores almost everything under it.
- command rg -. -z --no-messages -i -M 900 --no-ignore-parent -g '!.git' -g '!auto-save-list' -g '!.savehist' "$@" || ret=$?
+ command rg -n --heading -. -z --no-messages -i -M 900 --no-ignore-parent -g '!.git' -g '!auto-save-list' -g '!.savehist' "$@" || ret=$?
return $ret
}
[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
-source /usr/local/lib/err
+source /usr/local/lib/bash-bear
usage() {
cat <<'EOF'
uninstalled-file-die $f
fi
done
- if ! diff -q /a/bin/errhandle/err /usr/local/lib/err; then
+ if ! diff -q /a/bin/bash-bear-trap/bash-bear /usr/local/lib/bash-bear; then
uninstalled-file-die err
fi
if $check_installed; then
if ! $pull_reexec && [[ $source ]] && $pulla ; then
tmpf=$(mktemp)
m rsync -ra $source:/usr/local/bin/{mount-latest-subvol,check-subvol-stale} /usr/local/bin
- m rsync -ra $source:/usr/local/lib/err /usr/local/lib
+ m rsync -ra $source:/usr/local/lib/bash-bear /usr/local/lib
m scp $source:/a/bin/distro-setup/btrbk-run $tmpf
if ! diff -q $tmpf ${BASH_SOURCE[0]}; then
e "found different version on host $source. reexecing"
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-License-Identifier: Apache-2.0
-if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi
-shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4
-set -eE -o pipefail
-trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR
-# alternatively, using https://iankelling.org/git/?p=errhandle;a=tree
-# source /path/errhandle/err
-# on my machine
-source /a/bin/errhandle/err
+source /a/bin/bash-bear-trap/bash-bear
[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
-set -e; . /usr/local/lib/err; set +e
+set -e; . /usr/local/lib/bash-bear; set +e
# inspired from
# https://github.com/kdave/btrfsmaintenance
#!/bin/bash
if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
-source /a/bin/errhandle/err
+source /a/bin/bash-bear-trap/bash-bear
source /a/bin/bash_unpublished/source-state
if [[ $HOSTNAME != "$MAIL_HOST" ]]; then
if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
-source /a/bin/errhandle/err
+source /a/bin/bash-bear-trap/bash-bear
shopt -s nullglob
shopt -s dotglob
[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
-source /usr/local/lib/err
+source /usr/local/lib/bash-bear
shopt -s nullglob
#!/bin/bash
-source /a/bin/errhandle/err
+source /a/bin/bash-bear-trap/bash-bear
err-cleanup() {
echo 1 >~/.local/conflink
}
if ! $interactive; then
set -x
fi
-source /a/bin/errhandle/err
+source /a/bin/bash-bear-trap/bash-bear
mkdir -p ~/.local
err-cleanup() {
export LC_USEBASHRC=t; if [[ -s ~/.bashrc ]]; then . ~/.bashrc; fi
### setup
-source /a/bin/errhandle/err
+source /a/bin/bash-bear-trap/bash-bear
src="$(readlink -f -- "${BASH_SOURCE[0]}")"; src=${src%/*} # directory of this file
if [[ $EUID == 0 ]]; then
#!/bin/bash
-set -e; . /usr/local/lib/err; set +e
+set -e; . /usr/local/lib/bash-bear; set +e
[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
this_file="$(readlink -f -- "${BASH_SOURCE[0]}")"
if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
-source /usr/local/lib/err
+source /usr/local/lib/bash-bear
pre="${0##*/}:"
PATH="/sbin:$PATH"
m() { printf "$pre %s\n" "$*"; "$@"; }
if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
-source /usr/local/lib/err
+source /usr/local/lib/bash-bear
pre="${0##*/}:"
m() { printf "$pre %s\n" "$*"; "$@"; }
e() { printf "$pre %s\n" "$*"; }
#!/bin/bash
# Copyright (C) 2019 Ian Kelling
# SPDX-License-Identifier: AGPL-3.0-or-later
-source /a/bin/errhandle/err
+source /a/bin/bash-bear-trap/bash-bear
resolvuid=$(id -u systemd-resolve)
case $EUID in
shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR
-# alternatively, using https://iankelling.org/git/?p=errhandle;a=tree
-# source /path/errhandle/err
-# on my machine
-source /a/bin/errhandle/err
+source /a/bin/bash-bear-trap/bash-bear
[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
#!/bin/bash
-source /a/bin/errhandle/err
+source /a/bin/bash-bear-trap/bash-bear
e() { echo "$*"; "$@"; }
lnf() { /a/bin/lnf/lnf "$@"; }
#!/bin/bash
-set -e; . /usr/local/lib/err; set +e
+set -e; . /usr/local/lib/bash-bear; set +e
output=HDMI2
#set -x
#exec &> >(logger)
-source /a/bin/errhandle/err
+source /a/bin/bash-bear-trap/bash-bear
usage() {
cat <<'EOF'
shopt -s nullglob
-if [[ -s /usr/local/lib/err ]]; then
- source /usr/local/lib/err
-elif [[ -s /a/bin/errhandle/err ]]; then
- source /a/bin/errhandle/err
+if [[ -s /usr/local/lib/bash-bear ]]; then
+ source /usr/local/lib/bash-bear
+elif [[ -s /a/bin/bash-bear-trap/bash-bear ]]; then
+ source /a/bin/bash-bear-trap/bash-bear
else
echo "no err tracing script found"
exit 1
u /usr/local/bin/ncup <<'EOFOUTER'
#!/bin/bash
-source /usr/local/lib/err
+source /usr/local/lib/bash-bear
m() { printf "%s\n" "$*"; "$@"; }
err-cleanup() {
#!/bin/bash
if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
-source /a/bin/errhandle/err
+source /a/bin/bash-bear-trap/bash-bear
source /a/bin/bash_unpublished/source-state
if [[ $HOSTNAME != "$MAIL_HOST" ]]; then
# wrong
-source /b/errhandle/err
+source /b/bash-bear-trap/bash-bear
[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
# usage: HOST [mount-latest-subvol args]
-source /usr/local/lib/err
+source /usr/local/lib/bash-bear
script_dir=$(dirname $(readlink -f "$BASH_SOURCE"))
rsynctg="[$tg]"
fi
# R = relative, t = times, O = omit-dir-times, p = perms
-er rsync -RtOp bin/{mount-latest-subvol,check-subvol-stale} lib/err "root@$rsynctg:/usr/local" || continue
+er rsync -RtOp bin/{mount-latest-subvol,check-subvol-stale} lib/bash-bear "root@$rsynctg:/usr/local" || continue
# note: this can hang if we have an old nfs mount.
er ssh root@$tg timeout -s 9 600 /usr/local/bin/mount-latest-subvol "$@"
cd /
[[ $EUID == 0 ]] || exec sudo -E "$this_file" "$@"
-source /usr/local/lib/err
+source /usr/local/lib/bash-bear
usage() {
cat <<EOF
#
if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
-source /a/bin/errhandle/err
+source /a/bin/bash-bear-trap/bash-bear
shopt -s nullglob
shopt -s dotglob
#!/bin/bash
-set -e; . /usr/local/lib/err; set +e
+set -e; . /usr/local/lib/bash-bear; set +e
source /a/bin/ds/beet-data
source /b/bash_unpublished/source-semi-priv
#!/bin/bash
-set -e; . /usr/local/lib/err; set +e
+set -e; . /usr/local/lib/bash-bear; set +e
source /a/bin/ds/beet-data
for r in 1 2 3 4 5; do
#!/bin/bash
-if [[ -s /usr/local/lib/err ]]; then
- source /usr/local/lib/err
+if [[ -s /usr/local/lib/bash-bear ]]; then
+ source /usr/local/lib/bash-bear
else
exit 1
fi
i /usr/local/bin/ncup <<'EOFOUTER'
#!/bin/bash
-source /usr/local/lib/err
+source /usr/local/lib/bash-bear
m() { printf "%s\n" "$*"; "$@"; }
err-cleanup() {
# usage $0 [MAIL_HOST]
# setup things which involve being the primary host or not
-source /usr/local/lib/err
+source /usr/local/lib/bash-bear
script_name="${BASH_SOURCE[0]}"
script_name="${script_name##*/}"
#!/bin/bash
-set -e; . /usr/local/lib/err; set +e
+set -e; . /usr/local/lib/bash-bear; set +e
dossh=true
if (( $# >= 1 )); then
# ssh root@kdwg.b8.nz systemctl --now enable profanity
if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
-source /a/bin/errhandle/err
+source /a/bin/bash-bear-trap/bash-bear
source /a/bin/bash_unpublished/source-state
if [[ $HOSTNAME != "$HOST2" ]]; then
#!/bin/bash
-set -e; . /usr/local/lib/err; set +e
+set -e; . /usr/local/lib/bash-bear; set +e
while read -r line; do
# check that the profanity window is not focused
#!/bin/bash
-set -e; . /usr/local/lib/err; set +e
+set -e; . /usr/local/lib/bash-bear; set +e
remote=$1
fastcon=0
#!/bin/bash
-set -e; . /usr/local/lib/err; set +e
+set -e; . /usr/local/lib/bash-bear; set +e
xmpp_users=(
)
# note: turn this into an array if we ever add more
-my_lib_files=/a/bin/errhandle/err
+my_lib_files=/a/bin/bash-bear-trap/bash-bear
all_my_scripts=("${my_service_scripts[@]}" "${my_bin_files[@]}" $my_lib_files)
--- /dev/null
+/a/bin/bash-bear-trap/bash-bear
\ No newline at end of file
+++ /dev/null
-/a/bin/errhandle/err
\ No newline at end of file
#!/bin/bash
-set -e; . /usr/local/lib/err; set +e
+set -e; . /usr/local/lib/bash-bear; set +e
mpv --speed=1 --no-terminal --vo=null --volume=90 /a/bin/data/d20.wav
#!/bin/bash
-source /usr/local/lib/err
+source /usr/local/lib/bash-bear
usage() {
cat <<EOF
uninstalled-file-die $f
fi
done
- if ! diff -q /a/bin/errhandle/err /usr/local/lib/err; then
+ if ! diff -q /a/bin/bash-bear-trap/bash-bear /usr/local/lib/bash-bear; then
uninstalled-file-die err
fi
if $check_installed; then
exit 1
fi
-source /a/bin/errhandle/err
+source /a/bin/bash-bear-trap/bash-bear
status_file=/dev/shm/iank-status
shopt -s nullglob
[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
-source /a/bin/errhandle/err
+source /a/bin/bash-bear-trap/bash-bear
readonly this_file=$(readlink -f -- "${BASH_SOURCE[0]}")
readonly this_dir="${this_file%/*}"
script=$(readlink -f -- "$BASH_SOURCE")
[[ $EUID == 0 ]] || exec sudo -E "$script" "$@"
-source /usr/local/lib/err
+source /usr/local/lib/bash-bear
# Explaining this whole thing. The host amy is used by someone else,
# Copyright (C) 2019 Ian Kelling
# SPDX-License-Identifier: AGPL-3.0-or-later
-source /a/bin/errhandle/err
+source /a/bin/bash-bear-trap/bash-bear
[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
# Get screenshots from bow, discard them if they dont change much.
-source /usr/local/lib/err
+source /usr/local/lib/bash-bear
[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
dest_dir=/d/ziva-log