X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=brc;h=ff3b91fb84306bc7cee5ec924a20f37d34f8b314;hb=110b15e4a7b19cc520d2aa3f2584f4213b94f5b7;hp=7b0167468819caf211a64b56615af3fc36ba608c;hpb=602a1874cc11a7d371890cdae4c0dc982267ea89;p=distro-setup diff --git a/brc b/brc index 7b01674..ff3b91f 100644 --- a/brc +++ b/brc @@ -466,6 +466,10 @@ c() { } ccomp cd c +bwm() { + s bwm-ng -T avg -d +} + b() { local topb if (( ${#_iankdirb[@]} == 0 )); then @@ -874,6 +878,11 @@ ediff() { # mail related etail() { + ngset + tail -F /var/log/exim4/mainlog /var/log/exim4/*main -n 200 "$@" + ngreset +} +etailm() { tail -F /var/log/exim4/mainlog -n 200 "$@" } etail2() { @@ -882,6 +891,7 @@ etail2() { ccomp tail etail etail2 + # print exim old pids eoldpids() { local configtime pid piduptime now daemonpid @@ -1232,6 +1242,7 @@ ipp() { ifn() { # insensitive find + # -L = follow symlinks find -L . -not \( -name .svn -prune -o -name .git -prune \ -o -name .hg -prune -o -name .editor-backups -prune \ -o -name .undo-tree-history -prune \) -iname "*$**" 2>/dev/null @@ -1403,12 +1414,44 @@ nags() { } nmt() { - s nmtui-connect "$@" + # cant use s because sudo -i doesnt work for passwordless sudo command + case $EUID in + 0) + sudo nmtui-connect "$@" + ;; + *) + nmtui-connect "$@" + ;; + esac +} + + +ngset() { + if shopt nullglob >/dev/null; then + ngreset=false + else + shopt -s nullglob + ngreset=true + fi +} +ngreset() { + if $ngreset; then + shopt -u nullglob + fi } nopanic() { # shellcheck disable=SC2024 - sudo tee -a /var/log/exim4/paniclog-archive /dev/null || [[ $(systemctl is-active systemd-resolved ||:) != inactive ]]; then hr; m ser status systemd-resolved | cat || : - hr; m systemd-resolve --status | cat + hr; m resolvectl status | cat fi } @@ -1728,7 +1771,7 @@ sk() { local quotes others quotes=2048,2068,2086,2206 - others=2029,2033,2164 + others=2029,2033,2054,2164 shellcheck -W 999 -x -e $quotes,$others "$@" || return $? } @@ -2171,6 +2214,85 @@ s/^\Wcapability: (.*)/\1/;Ta;h;b "|sort -r } +# Run script by copying it to a temporary location first, +# and changing directory, so we don't have any open +# directories or files that could cause problems when +# remounting. +z() { + local tmp + tmp=$(type -p "$1") + if [[ $tmp ]]; then + cd $(mktemp -d) + cp -a "$tmp" . + shift + ./"${tmp##*/}" "$@" + else + "$@" + fi +} + + +# * spark +# spark 1 5 22 13 53 +# # => ▁▁▃▂▇ + +# The MIT License +# Copyright (c) Zach Holman, https://zachholman.com +# https://github.com/holman/spark + +# As of 2022-10-28, I reviewed github forks that had several newer +# commits, none had anything interesting. I did a little refactoring +# mostly to fix emacs indent bug. + +# Generates sparklines. +_spark_echo() +{ + if [ "X$1" = "X-n" ]; then + shift + printf "%s" "$*" + else + printf "%s\n" "$*" + fi +} + + +spark() +{ + local f tc + local n numbers= + + # find min/max values + local min=0xffffffff max=0 + + for n in ${@//,/ } + do + # on Linux (or with bash4) we could use `printf %.0f $n` here to + # round the number but that doesn't work on OS X (bash3) nor does + # `awk '{printf "%.0f",$1}' <<< $n` work, so just cut it off + n=${n%.*} + (( n < min )) && min=$n + (( n > max )) && max=$n + numbers=$numbers${numbers:+ }$n + done + + # print ticks + local ticks=(▁ ▂ ▃ ▄ ▅ ▆ ▇ █) + + # use a high tick if data is constant + (( min == max )) && ticks=(▅ ▆) + + tc=${#ticks[@]} + f=$(( ( (max-min) <<8)/( tc - 1) )) + (( f < 1 )) && f=1 + + for n in $numbers + do + _spark_echo -n ${ticks[$(( ((($n-$min)<<8)/$f) ))]} + done + _spark_echo +} + + # * misc stuff