# SPDX-License-Identifier: AGPL-3.0-or-later
# this gets sourced. shebang is just for file mode detection
-source /a/bin/errhandle/err
+# Use source ~/.bashrc instead of doing bash -l when running a script
+# so this can set extdebug and avoid the bash debugger.
+if [[ -s /a/bin/errhandle/err ]]; then
+ source /a/bin/errhandle/err
+elif [[ -s ~/.iank/err ]]; then
+ # shellcheck source=/a/bin/errhandle/err
+ source ~/.iank/err
+fi
# * settings
fi
if [[ -s /a/bin/small-misc-bash/ll-function ]]; then
- # shellcheck source=/a/bin/small-misc-bash/ll-function
source /a/bin/small-misc-bash/ll-function
elif [[ -s ~/.iank/ll-function ]]; then
+ # shellcheck source=/a/bin/small-misc-bash/ll-function
source ~/.iank/ll-function
fi
+
# * functions
find -L $1 -type f -not \( -name .svn -prune -o -name .git -prune \
-o -name .hg -prune -o -name .editor-backups -prune \
-o -name .undo-tree-history -prune \) \
- -exec bash -lc 'hr; echo "$1"; hr; cat "$1"' _ {} \; 2>/dev/null
+ -exec bash -c '. ~/.bashrc; hr; echo "$1"; hr; cat "$1"' _ {} \; 2>/dev/null
}
less /var/log/exim4/mainlog
}
eqcat() {
- exiqgrep -i | while read i; do
+ exiqgrep -i | while read -r i; do
exim -Mvh $i; hr; exim -Mvb $i; hr;
exigrep $i /var/log/exim4/mainlog; hr
done
}
grr() { # grep recursive
+ # Don't return 1 on nonmatch because this is meant to be
+ # interactive, not in a conditional.
if [[ ${#@} == 1 ]]; then
- grep --exclude-dir='*.emacs.d' --exclude-dir='*.git' -RiIP --color=auto "$@" .
+ grep --exclude-dir='*.emacs.d' --exclude-dir='*.git' -RiIP --color=auto "$@" . || [[ $? == 1 ]]
else
- grep --exclude-dir='*.emacs.d' --exclude-dir='*.git' -RiIP --color=auto "$@"
+ grep --exclude-dir='*.emacs.d' --exclude-dir='*.git' -RiIP --color=auto "$@" || [[ $? == 1 ]]
fi
}
rg() {
hr() { # horizontal row. used to break up output
- printf "$(tput setaf 5)█$(tput sgr0)%.0s" $(eval echo {1..${COLUMNS:-60}})
+ printf "$(tput setaf 5)█$(tput sgr0)%.0s" $(eval echo "{1..${COLUMNS:-60}}")
echo
}
esac
}
+psg () {
+ local x y help
+ help="Usage: psg [--help] GREP_ARGS
+grep ps and output in a nice format"
+ if [[ $1 == --help ]]; then
+ echo "$help"
+ return
+ fi
+ x=$(sudo ps -eF)
+ # final grep is because some commands tend to have a lot of trailing spaces
+ y=$(echo "$x" | grep -iP "$@" | grep -o '.*[^ ]') ||:
+ if [[ $y ]]; then
+ echo "$x" | head -n 1
+ echo "$y"
+ fi
+}
+
pubip() { curl -4s https://icanhazip.com; }
pubip6() { curl -6s https://icanhazip.com; }
whatismyip() { pubip; }
# shellcheck disable=SC2120
r() {
history -a # save history
+ trap ERR # this avoids a segfault
exit ${1:0}
# i had this redir, not sure why
# exit "$@" 2>/dev/null
# with root owned files.
#
if [[ $EUID != 0 || $1 == -* ]]; then
+ # shellcheck disable=SC2034
SUDOD="$PWD" sudo -i "$@"
else
"$@"