- # test existence / exists
- local ret=0
- for x in "$@"; do
- [[ -e "$x" || -L "$x" ]] || ret=1
- done
- return $ret
-}
-
-testmail() {
- declare -gi _seq; _seq+=1
- echo "test body" | m mail -s "test mail from $HOSTNAME, $_seq" "${@:-root@localhost}"
- # for testing to send from an external address, you can do for example
- # -aFrom:ian@iank.bid web-6fnbs@mail-tester.com
- # note in exim, you can retry a deferred message
- # s exim -M MSG_ID
- # MSG_ID is in /var/log/exim4/mainlog, looks like 1ccdnD-0001nh-EN
-}
-
-# use -eW to actually modify mailbox
-testsievelist() {
- sieve-filter ~/sieve/main.sieve "$@" >/a/tmp/slog 2> >(tail) && sed -rn '/^Performed actions:/{n;n;p}' /a/tmp/slog | sort -u
-}
-
-
-testsieve() {
- sieve-filter ~/sieve/main.sieve "$@"
-}
-
-testexim() {
- # testmail above calls sendmail, which is a link to exim/postfix.
- # it's docs don't say a way of adding an argument
- # to sendmail to turn on debug output. We could make a wrapper, but
- # that is a pain. Exim debug args are documented here:
- # http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html
- #
-# http://www.exim.org/exim-html-current/doc/html/spec_html/ch-building_and_installing_exim.html
-# note, for exim daemon, you can turn on debug options by
- # adding -d, etc to COMMONOPTIONS in
- # /etc/default/exim4
- # for testing external mail, you need the to address as final cmdline arg
- exim -d+tls -t <<'EOF'
-From: root@frodo.lan
-To: ian@mail.iankelling.org
-Subject: Testing Exim
-
-This is a test message.
-EOF
-}
-
-tm() {
- # timer in minutes
- # --no-config
- (sleep $(calc "$@ * 60") && mpv --no-config --volume 50 /a/bin/data/alarm.mp3) > /dev/null 2>&1 &
-}
-
-
-tu() {
- local s;
- local dir="$(dirname "$1")"
- if [[ -e $1 && ! -w $1 || ! -w $(dirname "$1") ]]; then
- s=s;
- fi
- $s teeu "$@"
-}
-
-tx() { # toggle set -x, and the prompt so it doesn't spam
- if [[ $- == *x* ]]; then
- set +x
- PROMPT_COMMAND=prompt_command
- else
- unset PROMPT_COMMAND
- PS1="\w \$ "
- set -x
- fi
+ # test existence / exists
+ local ret=0
+ for x in "$@"; do
+ [[ -e "$x" || -L "$x" ]] || ret=1
+ done
+ return $ret
+}
+
+
+tx() { # toggle set -x, and the prompt so it doesnt spam
+ if [[ $- == *x* ]]; then
+ set +x
+ PROMPT_COMMAND=prompt-command
+ # disabled due to issue on stretch, running ll we get error. something
+ # about the DEBUG trap is broken
+ # if [[ $TERM == *(screen*|xterm*|rxvt*) ]]; then
+ # trap 'settitle "$BASH_COMMAND"' DEBUG
+ # fi
+ else
+ # normally, i would just execute these commands in the function.
+ # however, DEBUG is not inherited, so we need to run it outside a function.
+ # And we want to run set -x afterwards to avoid spam, so we cram everything
+ # in here, and then it will run after this function is done.
+ #PROMPT_COMMAND='trap DEBUG; unset PROMPT_COMMAND; PS1="\w \$ "; set -x'
+
+ unset PROMPT_COMMAND
+ PS1="\w \$ "
+ set -x
+ fi