}
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() {
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() {
}
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() {
}
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
}
nopanic() {
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
}
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,2054,2164
+ shellcheck -W 999 -x -e $quotes,$others "$@" || return $?
}