+
+# my profanity
+#
+myprof() {
+ pushd /home/iank/.local/share/profanity/chatlogs/iank_at_fsf.org/rooms/office_at_conference.fsf.org
+ logs=(*)
+ logcount=${#logs[@]}
+ if (( logcount > 15 )); then
+ i=$(( logcount - 15 ))
+ else
+ i=0
+ fi
+ # usually do this on monday, sometimes later
+ if [[ $(date +%A) == Monday ]]; then
+ min_date=$(date -d 'monday 2 weeks ago' +%s)
+ else
+ min_date=$(date -d 'monday 3 weeks ago' +%s)
+ fi
+ for (( ; i < logcount; i++ )); do
+ log=${logs[$i]}
+ d=$(date -d "$(head -n1 $log|awk '{print $1}')" +%s)
+ if (( d < min_date )); then
+ continue
+ fi
+ if awk '$3 == "iank:"' $log | sed -r 's/^(.{10}).(.{8})[^ ]+(.*)/\1_\2\3/' | grep .; then
+ hr
+ fi
+ done
+ 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
+prof-recent() {
+ case $HOSTNAME in
+ kd)
+ prof-recent-local
+ ;;
+ *)
+ ssh b8.nz 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)
+ dates=("$(date +%Y_%m_%d)" "$(date -d '1 day ago' +%Y_%m_%d)" )
+ for d in /d/p/profanity/chatlogs/iank_at_fsf.org/!(rooms); do
+ files=()
+ for date in ${dates[@]}; do
+ f=$d/$date.log
+ if [[ -e $f ]]; then
+ files+=($f)
+ fi
+ done
+ if (( ${#files[@]} >= 1 )); then
+ cat ${files[@]} | tail
+ hr
+ fi
+ 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