}
ta() {
- bn ta "$@"
+ bn tailf "$@"
}
+tag() {
+ _bntmp() {
+ local file
+ file="$1"
+ tailf "$file" | gr --line-buffered "$@"
+ }
+ bn _bntmp "$@"
+}
+
ccomp tail etail etail2 ta
+_cron-test() {
+ tailf /var/log/syslog | gr --line-buffered cron
+}
+
+cron-test() {
+ echo "cron will check for new files in about $(( 60 - $(date +%S) + 2 )) seconds"
+ bn _cron-test
+}
+
# ran into this online, trying it out
detach() {
( "$@" &>/dev/null & disown )
jrt() { journalctl -e -n100000 -o short-full "$@"; }
jr() { journalctl -e -n100000 "$@" ; }
jrf() { SYSTEMD_COLORS=true bn journalctl -n1000 -f "$@" ; }
+jrfg() {
+ _bntmp() { SYSTEMD_COLORS=true journalctl -n1000 -f | gr --line-buffered "$@"; }
+ bn _bntmp "$@"
+}
jru() {
- # the invocation id is "assigned each time the unit changes from an inactive
- # state into an activating or active state" man systemd.exec
- journalctl -e --no-tail -u exim4 _SYSTEMD_INVOCATION_ID="$(systemctl show -p InvocationID --value $1)"
+ SYSTEMD_COLORS=true bn journalctl -n1000 -f -u "$@" ;
+}
+jrug() {
+ _bntmp() {
+ local unit
+ unit="$1"
+ shift
+ SYSTEMD_COLORS=true journalctl -n1000 -f -u "$unit" | gr --line-buffered "$@"
+ }
+ bn _bntmp "$@"
}
ccomp journalctl jr jrf jru
#
# The name bn is not special.
#
+# Note: if you want to tail -f | grep, wrap it in a function
+# first, and use grep --line-buffered (because we are piping to a pipe).
+#
# Note: colorization will need to be turned on since it captures
# output to a pipe, eg: SYSTEMD_COLORS=true bn journalctl -f
-bn() {
+#
+_bn() {
local line lwlc i
- {
- "$@" |& while read -r line; do
- # lwlc = line wrapped line count.
- lwlc=$(( ${#line} / COLUMNS + 1 ))
- # from man terminfo
- # tput sc = \e7 = save cursor
- # tput rc = \e8 = restore cursor
- # tput hpa 0 = \e[1G = move cursor to column 0
- # tput il X = \e[XL = insert X lines
- # tput ind = \eD = (according to
- # https://superuser.com/questions/1106674/how-to-add-blank-lines-above-the-bottom-in-terminal
- # But I can't verify because cannot be captured into a var from tput.)
- #\e[XA = up X lines
- for (( i=0; i < lwlc; i++ )); do
- echo -ne "\eD"
- done
- echo -ne "\e7\e[${lwlc}A\e[1G\e[${lwlc}L$line\e8"
+ "$@" |& while read -r line; do
+ # lwlc = line wrapped line count.
+ lwlc=$(( ${#line} / COLUMNS + 1 ))
+ # from man terminfo
+ # tput sc = \e7 = save cursor
+ # tput rc = \e8 = restore cursor
+ # tput hpa 0 = \e[1G = move cursor to column 0
+ # tput il X = \e[XL = insert X lines
+ # tput ind = \eD = (according to
+ # https://superuser.com/questions/1106674/how-to-add-blank-lines-above-the-bottom-in-terminal
+ # But I can't verify because cannot be captured into a var from tput.)
+ #\e[XA = up X lines
+ for (( i=0; i < lwlc; i++ )); do
+ echo -ne "\eD"
done
- } &
+ echo -ne "\e7\e[${lwlc}A\e[1G\e[${lwlc}L$line\e8"
+ done
+}
+bn() {
+ # We wrap a function rather than a long {} so that it looks nicer in
+ # job control output.
+ _bn "$@" &
}
# shellcheck disable=SC2120
done
}
+
+brc3() {
+ source /a/c/brc3
+}
+
# * stuff that makes sense to be at the end
break
fi
done
- paths="/p/c /b/"
+ paths="/b/"
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 -- "$*" ||:
localai() {
schroot -c bookworm
- }
+}
+
+spdx() {
+ local out i input pw
+ out=$(gpg -q -d ~/.spd/spd/spd_data.gpg 2>/dev/null | gr "$@")
+ if [[ $out == *$'\n'* ]]; then
+ i=0
+ while read -r line; do
+ printf "$i %s\n" "$line" | awk -F'\t' '{print $1,$2}'
+ i=$(( i + 1 ))
+ done <<<"$out"
+ read -r input
+ i=0
+ while read -r line; do
+ if [[ $input == "$i" ]]; then
+ out="$line"
+ break
+ fi
+ i=$(( i + 1 ))
+ done <<<"$out"
+ fi
+ pw=$(printf "$i %s\n" "$out" | awk -F'\t' '{print $3}')
+ ( { printf "%s" "$pw" | xclip -selection clipboard && sleep 15 && echo " " | xclip -selection clipboard; } & )
+}
export BASEFILE_DIR=/a/bin/fai-basefiles
--- /dev/null
+#!/bin/bash
+
+## command where their main reason to exist is for documentation purposes,
+# and I have no desire to always load them into my shell.
+
+# $1 = snapshot
+btrfs-snapshot-rw() {
+ # -ts = type snapshot
+ # -f = force, required to overcome this error:
+ #
+ # ERROR: cannot flip ro->rw with received_uuid set, use force option
+ # -f if you really want unset the read-only status. The value of
+ # received_uuid is used for incremental send, consider making a
+ # snapshot instead. Read more at btrfs-subvolume(8) and Subvolume
+ # flags.
+ #
+ btrfs property set -f -ts "$1" ro false
+}
+
+# $1 = snapshot
+btrfs-snapshot-ro() {
+ btrfs property set -f -ts "$1" ro true
+}
sudo rm -fv /etc/systemd/system/profanity.service
case $HOSTNAME in
kd)
+ # i dunno why i put it here
ln -sfT /d/p/profanity ~/.local/share/profanity
ln -sfT /d/p/profanity-config ~/.config/profanity
source /a/bin/bash_unpublished/source-state
--- /dev/null
+#!/usr/bin/python3
+# I, Ian Kelling, follow 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, I plan to change
+# to a recommended GPL license.
+
+# Copyright 2024 Ian Kelling
+
+# 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.
+
+
+import sys
+from pprint import pprint
+from i3ipc import Connection, Event
+
+
+def main():
+ i3 = Connection()
+ win = i3.get_tree().find_focused()
+ if not win:
+ exit(1)
+
+ if not win.name == "profanity — Konsole":
+ exit(1)
+ # debug
+ #pprint(win.name)
+ #pprint(vars(win))
+
+
+if __name__ == "__main__":
+ main()
while read -r line; do
# check that the profanity window is not focused
- if ! i3-msg -t get_tree | jq -e '.nodes[].nodes[].nodes[].nodes[] | select(.focused==true and .name=="profanity — Konsole") |.name' &>/dev/null; then
+ if ! /a/c/i3-check-profanity &>/dev/null; then
# the profanity tag makes it so new notification replaces old.
dunstify -h string:x-dunst-stack-tag:profanity $line
fi
ruben
zoe
jtuttle
+ ekokao
)
# start emacs daemon for profanity if it doesnt exist.