Add stuff.

This commit is contained in:
barnold 2022-05-02 20:21:42 +01:00
parent 96c4e1673c
commit aeb79cfb4f
6 changed files with 213 additions and 0 deletions

66
bgedit-screen-tmux.sh Executable file
View File

@ -0,0 +1,66 @@
#!/bin/sh
#
# Copyright (C) 2020 Kevin J. McCarthy <kevin@8t8.us>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Invoke a background edit session in a new GNU Screen or tmux window.
#
# This script is derived from Aaron Schrab's tmuxwait script, posted to
# mutt-dev at
# <http://lists.mutt.org/pipermail/mutt-dev/Week-of-Mon-20200406/000591.html>.
#
# If you run mutt inside screen or tmux, add to your muttrc:
# set background_edit
# set editor = '/path/to/bgedit-screen-tmux.sh [youreditor]'
#
# It may also be useful to modify something like contrib/bgedit-detectgui.sh
# to look for the $STY or $TMUX environment variables and set those
# configuration variables appropriately.
#
set -e
if [ "$#" -lt 2 ]; then
echo "Usage: $0 editor tempfile" >&2
exit 1
fi
editor=$1
shift
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT INT QUIT
mkfifo "$tmpdir/status"
cat >"$tmpdir/run" <<END_SCRIPT
exitval=1
trap 'echo \$exitval > "$tmpdir/status"' EXIT INT QUIT
$editor "\$@"
exitval=\$?
END_SCRIPT
if test x$STY != x; then
screen -X screen /bin/sh "$tmpdir/run" "$@"
elif test x$TMUX != x; then
tmux neww /bin/sh "$tmpdir/run" "$@"
else
echo "Not running inside a terminal emulator" >&2
exit 1
fi
read exitval <"$tmpdir/status"
exit "$exitval"

88
em Executable file
View File

@ -0,0 +1,88 @@
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
shopt -s globstar nullglob
function show_help ()
{
cat >&2 <<EOF
usage: $(basename "$0") [OPTION...]
OPTIONS
-v Verbosity. Repeat for more verbosity.
-h This help.
Examples
\$ $(basename "$0")
\$ $(basename "$0") -vv
EOF
exit 1
}
#------------------------------------------------------------------------------
declare -i VERBOSITY=0
while getopts ":hv" opt
do
case $opt in
v ) ((++VERBOSITY)) ;;
* ) show_help ;;
esac
done
shift $((OPTIND - 1))
#------------------------------------------------------------------------------
function squawk ()
{
local -i NVOL=$1; shift
if ((0 == NVOL)); then
echo >&2 "$(basename "$0") $(date +'%T %Z')" "$@"
exit 1
elif ((NVOL <= VERBOSITY)); then
echo "$(basename "$0") $(date +'%T %Z')" "$@"
fi
return 0
}
#------------------------------------------------------------------------------
# Express the VERBOSITY as an option string.
function vopt ()
{
local str=""
if ((0 < VERBOSITY)); then
str="-v"
fi
for ((i = 1; i < VERBOSITY; i++)); do
str="${str}v"
done
echo "$str"
return 0
}
#------------------------------------------------------------------------------
squawk 1 "$(date --iso) started."
if [[ -n "${INSIDE_EMACS:-}" ]]; then
squawk 1 "I'm inside emacs..."
emacsclient "$@"
else
squawk 1 "Not inside emacs..."
# Attempt to clean up the possible messes that emacs makes.
if ! pgrep --uid "$LOGNAME" --full 'emacs --daemon' >/dev/null
then
squawk 1 "No daemon, clearing lock..."
rm -f ~/.emacs.d/.emacs.desktop.lock
elif ! [[ -S /run/user/$UID/emacs/server ]]
then
squawk 1 "Killing daemon that lost its socket..."
pkill --signal SIGKILL --uid "$LOGNAME" --full 'emacs --daemon'
squawk 1 "Clearing lock..."
rm -f ~/.emacs.d/.emacs.desktop.lock
fi
squawk 1 "daemon state should be good, so starting client..."
exec emacsclient --tty --alternate-editor="" "$@"
fi
squawk 1 "done."
exit 0

3
lsC Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
LC_COLLATE=C ls "$@"

19
swaks-auth-465.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
shopt -s globstar nullglob
swaks --ehlo $(hostname) \
--to 'recipient@example.com' \
--from barnold@tilde.club \
--h-Subject 'Sent via smtps' \
--server localhost \
-tlsc \
--port 465 \
--auth PLAIN \
--auth-user barnold
#--auth-password "$(cat ~/.local/private/s3kret.txt)"
exit 0

15
swaks-relay-localhost.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
shopt -s globstar nullglob
swaks --ehlo $(hostname) \
--to 'recipient@example.com' \
--from barnold@tilde.club \
--h-From 'barnold@example.com' \
--h-Subject 'Try real envelope but forged hdr from' \
--server localhost
exit 0

22
tm Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
shopt -s globstar nullglob
# Fix function keys, Home and End at least.
declare -x TERM=rxvt-unicode-256color
if ! tmux has-session -t tm1
then
# About mutt: the weird bash incantation is the only way I found
# to combine both of: starts with tty flow-control disabled; can
# quit mutt and get a shell.
tmux new-session -d -s tm1 -n "mutt" "bash -i -c 'mutt -y; bash -i'"
tmux set-option set-titles on
tmux new-window -n "slrn" "bash -i -c 'slrn; bash -i'"
tmux new-window -n "bash" "bash -i"
tmux select-window -t "mutt"
fi
exec tmux attach-session -t tm1