X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=brc;h=5e8776de929ba02c83b63df934724fa29561b49e;hb=110af45c7f752203344f1578302be6c9103fd851;hp=a29651bb6589bc0a38446415d3b06212cdec1791;hpb=cb002f1dc386fdf42b30133351b90e6d2a662174;p=distro-setup diff --git a/brc b/brc index a29651b..5e8776d 100644 --- a/brc +++ b/brc @@ -15,8 +15,8 @@ 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 - source $bashrc_dir/err + # shellcheck source=/a/bin/errhandle/err + source $bashrc_dir/err fi fi @@ -673,8 +673,20 @@ khcopy() { # ya, hacky hardcoded hostnames in 2023. we could do better hssh-update() { - local -a failed_hosts - for host in kd x3.office.fsf.org syw; do + local -a failed_hosts hosts + case $HOSTNAME in + sy|kd) + hosts=( + kd x3.office.fsf.org syw + ) + ;; + x3) + hosts=( + b8.nz sywg.b8.nz + ) + ;; + esac + for host in ${hosts[@]}; do e $host if ! scp /b/fai/fai/config/files/usr/local/bin/hssh/IANK root@$host:/usr/local/bin/hssh; then failed_hosts+=($host) @@ -700,7 +712,7 @@ for field in {1..20}; do done # h1 = head -n1 for num in {1..9}; do - eval h$num"() { head -n$num; }" + eval h$num"() { head -n$num || [[ \$? == 141 ]]; }" done @@ -1578,14 +1590,16 @@ pst() { pstree -apnA } -jtail() { - journalctl -n 10000 -f "$@" -} -jr() { journalctl "$@" ; } -jrf() { journalctl -f "$@" ; } +# journalctl with times in the format the --since= and --until= options accept +jrt() { journalctl -e -n100000 -o short-full "$@"; } +jr() { journalctl -e -n100000 "$@" ; } +jrf() { journalctl -n1000 -f "$@" ; } jru() { - journalctl -u exim4 _SYSTEMD_INVOCATION_ID="$(systemctl show -p InvocationID --value $1)" + # 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)" } +ccomp journalctl jr jrf jru @@ -1694,6 +1708,11 @@ histrm() { history -w } +# history without the date +histplain() { + history "$@" | cut -d' ' -f 7- +} + ccomp grep k ks ksu histrm @@ -1732,11 +1751,19 @@ mkdir() { command mkdir -p "$@"; } nags() { # https://github.com/HenriWahl/Nagstamon/issues/357 - if ! pgrep -f /usr/lib/notification-daemon/notification-daemon >/dev/null; then - /usr/lib/notification-daemon/notification-daemon & + if ! pgrep -f /usr/bin/dunst >/dev/null; then + /usr/bin/dunst & fi /usr/bin/nagstamon & } +prof() { + if ! pgrep -f /usr/bin/dunst >/dev/null; then + /usr/bin/dunst & + fi + profanity "$@" +} + + nmt() { # cant use s because sudo -i doesnt work for passwordless sudo command @@ -2103,19 +2130,32 @@ sgu() { sk() { - - # disable a warning with: # shellcheck disable=SC2206 # reasoning # see bash-template/style-guide.md for justifications local quotes others - quotes=2048,2068,2086,2206 + quotes=2048,2068,2086,2206,2254 others=2029,2033,2054,2164 shellcheck -W 999 -x -e $quotes,$others "$@" || return $? } +# sk with quotes. For checking scripts that we expect to take untrusted +# input in order to verify we quoted vars. +skq() { + local others + others=2029,2033,2054,2164 + shellcheck -W 999 -x -e $others "$@" || return $? +} +skgit() { + local f + for f in $(i s | awk '$1 == "modified:" {print $2}'); do + if [[ $(head -n1 "$f") == '#!/bin/bash'* ]]; then + sk $f + fi + done +} # sl: ssh, but firsh rsync our bashrc and related files to a special # directory on the remote host if needed. @@ -2678,6 +2718,34 @@ spark() pdfwc() { local f; for f; do echo "$f" "$(pdfinfo "$f" | awk '/^Pages:/ {print $2}')"; done } + +# nvm install script appended this to my .bashrc. I dont want to run it all the time, +# so put it in a function. +nvm-init() { + export NVM_DIR="$HOME/.nvm" + # shellcheck disable=SC1091 # may not exist, & third party + [ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh" # This loads nvm + # shellcheck disable=SC1091 # may not exist, & third party + [ -s "$NVM_DIR/bash_completion" ] && source "$NVM_DIR/bash_completion" # This loads nvm bash_completion +} + + +leap-year() { + if date -d 'february 29' &>/dev/null; then + year_days=366 + else + year_days=365 + fi + echo $year_days +} + +# on-battery +on-bat() { + if [[ -e /sys/class/power_supply/AC/online && $(