schroot -c buster -- anki
}
+daycat() {
+ ngset
+ hrcat /m/md/daylert/{cur,new}/*
+ ngreset
+}
+dayclear() {
+ ngset
+ rm -f /m/md/daylert/{cur,new}/*
+}
+
+
acat() {
ngset
hrcat /m/md/alerts/{cur,new}/*
# 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
t s w
}
+
+# help me focus. opens 2 windows.
focus() {
/p/c/proc/focus/linux-amd64/focus &
watcharb5
}
+# Display a list of the active window title
+# i've been on with 10 second samples going back
+# 5 minutes. If I've been on one window for 10 seconds
+# or longer, then display the second count.
+#
+# Press any key to exit.
watcharb5() {
local char ret
- killall arbtt-capture ||:
+ killall arbtt-capture &>/dev/null ||:
rm -f ~/.arbtt/capture.log
arbtt-capture --sample-rate=10 &
- clear
while true; do
arb5
ret=0
killall arbtt-capture ||:
return 0
fi
- clear
done
}
arb5() {
- local i l sec
- i=0
+ local i j l sec blanks line
+ local -a arbtt_lines
if [[ ! -e ~/.arbtt/capture.log ]]; then
sleep 5
fi
- # https://stackoverflow.com/questions/56486272/how-to-concat-multiple-fields-to-same-line-with-jq
- arbtt-dump -l 30 -t json | jq -r '.[] | [ ( .inactive / 1000 | floor ) , ( .windows[] | select (.active == true) |.title) ] | @tsv' \
- | tac | while read -r sec l; do
- if (( i % 6 == 0 && i >= 2 )); then
- echo "## $(( i / 6 + 1 )) ##"
- fi
- if (( sec > 10 )); then
- printf "%3d %s\n" $sec "$l"
- else
- printf " %s\n" "$l"
- fi
- i=$(( i + 1 ))
+ blanks=$(( LINES - 34 ))
+ for (( i=0; i < blanks; i++ )); do
+ echo
done
+
+ {
+ i=0
+ j=0
+ # https://stackoverflow.com/questions/56486272/how-to-concat-multiple-fields-to-same-line-with-jq
+ arbtt_lines=$(arbtt-dump -l 30 -t json | \
+ jq -r '.[] | [ ( .inactive / 1000 | floor ) , ( .windows[] | select (.active == true) |.title) ] | @tsv' | tac)
+ for line in "${arbtt_lines[@]}"; do
+ read -r sec l <<<"$line"
+ if (( j >= LINES )); then
+ break
+ fi
+ if (( i % 6 == 0 && i >= 2 )); then
+ j=$(( j + 1 ))
+ echo "## $(( i / 6 + 1 )) ##"
+ fi
+ if (( sec > 10 )); then
+ printf "%3d %s\n" $sec "$l" | sed -r "s/^(.{$COLUMNS}).*/\1/"
+ else
+ printf " %s\n" "$l" | sed -r "s/^(.{$COLUMNS}).*/\1/"
+ fi
+ i=$(( i + 1 ))
+ j=$(( j + 1 ))
+ done
+ while (( j < 34 && j < LINES )); do
+ echo
+ j=$(( j + 1 ))
+ done
+ } | tac
}
arbttlog() {
popd
}
+
+# Tail all recent prof logs. Copying from profanity has unwanted line breaks
+# especially for links.
+profr() {
+ case $HOSTNAME in
+ kd)
+ profr-local
+ ;;
+ *)
+ ssh b8.nz profr-local
+ ;;
+ esac
+}
+
+profr-local() {
+ local d0 d1
+ local -a files
+ d0="$(date +%Y_%m_%d).log"
+ d1="$(date -d '1 day ago' +%Y_%m_%d).log"
+ ngset
+ files=(/d/p/profanity/chatlogs/iank_at_fsf.org/{*,rooms/*}/{$d0,$d1})
+ ngreset
+ if (( ${#files[@]} > 0 )); then
+ cat "${files[@]}" | sort | tail -n 40
+ fi
+}
+
+
# Tail pms in the last day, for the case where we restart profanity and
# didn't check for pms beforehand. Assume the most recent logs are on kd.
# If that isn't the case, use prof-recent-local
;;
esac
}
-
prof-recent-local() {
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)
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
}