spam-ascii: "*" dumps entire ~/ascii; alias quotes $0 to preserve it
Some checks failed
Close stale issues / stale (push) Has been cancelled

This commit is contained in:
2026-04-22 07:00:52 -07:00
parent 079bee5774
commit 065686f341
2 changed files with 11 additions and 2 deletions

View File

@@ -158,7 +158,7 @@ aliases = {
SB = "SCROLLBACK";
SBAR = "STATUSBAR";
SIGNOFF = "QUIT";
SPAM = "EXEC -out ~/.local/bin/spam-ascii $0";
SPAM = "EXEC -out ~/.local/bin/spam-ascii '$0'";
SV = "MSG * Irssi $J ($V) - http://www.irssi.org";
T = "TOPIC";
UB = "UNBAN";

View File

@@ -3,6 +3,7 @@
# spam-ascii — cat a file from ~/ascii given a partial/fuzzy name.
#
# Resolution order:
# 0. pattern `*` → cat every file in ~/ascii (sorted)
# 1. exact filename match: ~/ascii/<pattern>
# 2. exact name + common extension: <pattern>.txt, .ans, .asc
# 3. first case-insensitive *substring* match (sorted alphabetically)
@@ -14,12 +15,20 @@ set -eu
pattern=${1:-}
if [ -z "$pattern" ]; then
echo "usage: spam-ascii <pattern>"
echo "usage: spam-ascii <pattern> (pattern `*` dumps everything)"
exit 1
fi
dir="$HOME/ascii"
# 0. `*` → dump the whole collection.
if [ "$pattern" = "*" ]; then
find -L "$dir" -maxdepth 1 -type f -print0 2>/dev/null \
| sort -z \
| xargs -0 cat
exit 0
fi
# 1 + 2. Try exact name, then exact + common ASCII-art extensions.
for candidate in \
"$dir/$pattern" \