spam-ascii: "*" dumps entire ~/ascii; alias quotes $0 to preserve it
Some checks failed
Close stale issues / stale (push) Has been cancelled
Some checks failed
Close stale issues / stale (push) Has been cancelled
This commit is contained in:
@@ -158,7 +158,7 @@ aliases = {
|
|||||||
SB = "SCROLLBACK";
|
SB = "SCROLLBACK";
|
||||||
SBAR = "STATUSBAR";
|
SBAR = "STATUSBAR";
|
||||||
SIGNOFF = "QUIT";
|
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";
|
SV = "MSG * Irssi $J ($V) - http://www.irssi.org";
|
||||||
T = "TOPIC";
|
T = "TOPIC";
|
||||||
UB = "UNBAN";
|
UB = "UNBAN";
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
# spam-ascii — cat a file from ~/ascii given a partial/fuzzy name.
|
# spam-ascii — cat a file from ~/ascii given a partial/fuzzy name.
|
||||||
#
|
#
|
||||||
# Resolution order:
|
# Resolution order:
|
||||||
|
# 0. pattern `*` → cat every file in ~/ascii (sorted)
|
||||||
# 1. exact filename match: ~/ascii/<pattern>
|
# 1. exact filename match: ~/ascii/<pattern>
|
||||||
# 2. exact name + common extension: <pattern>.txt, .ans, .asc
|
# 2. exact name + common extension: <pattern>.txt, .ans, .asc
|
||||||
# 3. first case-insensitive *substring* match (sorted alphabetically)
|
# 3. first case-insensitive *substring* match (sorted alphabetically)
|
||||||
@@ -14,12 +15,20 @@ set -eu
|
|||||||
|
|
||||||
pattern=${1:-}
|
pattern=${1:-}
|
||||||
if [ -z "$pattern" ]; then
|
if [ -z "$pattern" ]; then
|
||||||
echo "usage: spam-ascii <pattern>"
|
echo "usage: spam-ascii <pattern> (pattern `*` dumps everything)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dir="$HOME/ascii"
|
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.
|
# 1 + 2. Try exact name, then exact + common ASCII-art extensions.
|
||||||
for candidate in \
|
for candidate in \
|
||||||
"$dir/$pattern" \
|
"$dir/$pattern" \
|
||||||
|
|||||||
Reference in New Issue
Block a user