X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=brc;h=c3747cf97e5a8b6f4e3de521db69f401c10b6281;hb=5c8530653c87af3757a2c649772e0405bcd143a0;hp=b0f8846bef148f95392839e8e32808ef66893b54;hpb=75e62ecbdabb055ef8d556e2e3aad7117557eb92;p=distro-setup diff --git a/brc b/brc index b0f8846..c3747cf 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 @@ -683,7 +687,7 @@ chrbind() { chumount() { local d # dev/pts needed for pacman signature check - for d in dev proc sys dev/pts; do + for d in dev/pts dev proc sys; do [[ -d $d ]] if mountpoint $d &>/dev/null; then m s umount $d @@ -779,6 +783,19 @@ despace() { done } +# get ipv4 ip from HOST. or if it is already a number, return that +hostip() { + local host="$1" + case $host in + [0-9:]) + echo "$host" + ;; + *) + getent ahostsv4 "$host" | awk '{ print $1 }' | head -n1 + ;; + esac +} + dig() { command dig +nostats +nocmd "$@" } @@ -816,7 +833,10 @@ digdiff() { dt() { date "+%A, %B %d, %r" "$@" } -ccomp date dt +dtr() { + date -R "$@" +} +ccomp date dt dtr dus() { # du, sorted, default arg of du -sh ${@:-*} | sort -h @@ -824,7 +844,7 @@ dus() { # du, sorted, default arg of ccomp du dus -e() { echo "$@"; } +e() { printf "%s\n" "$*"; } # echo args ea() { @@ -860,7 +880,11 @@ ediff() { etail() { tail -F /var/log/exim4/mainlog -n 200 "$@" } -ccomp tail etail +etail2() { + tail -F /var/log/exim4/mymain -n 200 "$@" +} + +ccomp tail etail etail2 # print exim old pids eoldpids() { @@ -920,14 +944,18 @@ eless() { } ccomp less eless eqcat() { - exiqgrep -i -o 60 | while read -r i; do + exiqgrep -ir.\* -o 60 | while read -r i; do hlm exim -Mvc $i echo hlm exigrep $i /var/log/exim4/mainlog | cat ||: done } eqrmf() { - exiqgrep -i | xargs exim -Mrm + # other ways to get the list of message ids: + # exim -bp | awk 'NF == 4 {print $3}' + # # this is slower 160ms, vs 60. + # exipick -i + exiqgrep -ir.\* | xargs exim -Mrm } econfdevnew() { @@ -960,6 +988,14 @@ faf() { # find all files. use -L to follow symlinks -o -name .undo-tree-history -prune \) -type f 2>/dev/null } +# full path without resolving symlinks +fp() { + local dir base + base="${1##*/}" + dir="${1%$base}" + printf "%s/%s\n" $(cd $dir; pwd) "$base" +} + # mail related frozen() { @@ -1539,7 +1575,7 @@ resolvcat() { grep '^ *hosts:' /etc/nsswitch.conf if systemctl is-enabled systemd-resolved &>/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 } @@ -1689,23 +1725,15 @@ sgu() { sk() { - # note, if you do something like this - # x=( prefix* ) - # then disable the warning with: - # shellcheck disable=SC2206 # globbing is intended - - # 2029: "unescaped, this expands on the client side.": yes, I know how ssh works - # 2164: "Use 'cd ... || exit' or 'cd ... || return' in case cd fails.": i have automatic error handling - # 2086: unquoted $var: Quoting every var I set is way too much quotes. - # 2068: Double quote array expansions to avoid re-splitting elements: same as above. - # 2033: command arg is a function name: too many false positives. - + # disable a warning with: + # shellcheck disable=SC2206 # reasoning - # these ones I had disabled, but without a good written explanation, so enabling them temporarily - # 2046: unquoted $(cmd) - # 2119: Functions with optional args get bad warnings when none are passed. + # see bash-template/style-guide.md for justifications - shellcheck -W 999 -x -e 2029,2164,2086,2068,2033 "$@" || return $? + local quotes others + quotes=2048,2068,2086,2206 + others=2029,2033,2164 + shellcheck -W 999 -x -e $quotes,$others "$@" || return $? }