}
ccomp cd c
+bwm() {
+ s bwm-ng -T avg -d
+}
+
b() {
local topb
if (( ${#_iankdirb[@]} == 0 )); then
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
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 "$@"
}
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
ccomp du dus
-e() { echo "$@"; }
+e() { printf "%s\n" "$*"; }
# echo args
ea() {
# mail related
etail() {
+ ngset
+ tail -F /var/log/exim4/mainlog /var/log/exim4/*main /var/log/exim4/paniclog /var/log/exim4/*panic -n 200 "$@"
+ ngreset
+}
+etailm() {
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() {
}
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() {
-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() {
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
}
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 </var/log/exim4/paniclog; sudo truncate -s0 /var/log/exim4/paniclog
+ ngset
+ for f in /var/log/exim4/paniclog /var/log/exim4/*panic; do
+ base=${f##*/}
+ if [[ -s $f ]]; then
+ echo ================== $f =============
+ s tee -a /var/log/exim4/$base-archive <$f
+ s truncate -s0 $f
+ fi
+ done
+ ngreset
}
p8() { ping "$@" 8.8.8.8; }
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
}
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 $?
}
"|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