Commit 9fab2bb

xxwhirlpool  ·  2026-05-14 11:50:06 -0400 EDT
parent 4b0fa95
paste into stdin for `weasel` & `passive`; IRC spellcheck
3 files changed,  +53, -26
+1, -0
1@@ -8,3 +8,4 @@ colors {
2 	unread purple
3 	prompt green
4 }
5+spell-check true
+26, -13
 1@@ -6,13 +6,13 @@
 2 # https://matt.might.net/articles/shell-scripts-for-passive-voice-weasel-words-duplicates/
 3 
 4 # vars
 5-passive_word_dir="$HOME/.config/wordfiles"
 6-passive_word_file="$passive_word_dir/passive"
 7+passive_worddir="$HOME/.config/wordfiles"
 8+passive_wordfile="$passive_worddir/passive"
 9 
10 # basic functions
11 usage_help() {
12-	echo "Usage: passive [FILE]"
13-	exit 1
14+	echo "Usage: passive [OPTIONS]"
15+	echo "Options: -f | -h"
16 }
17 
18 gum_echo() {
19@@ -26,17 +26,30 @@ die() {
20 
21 # check if word file exists
22 wordfile_check() {
23-	[[ -f "$passive_word_file" ]] || die "passive word file does not exist"
24+	[[ -f "$passive_wordfile" ]] || die "passive word file does not exist"
25 }
26 
27 # cat the word file into a var
28-words=$(wordfile_check && cat "$passive_word_file")
29+words=$(wordfile_check && cat "$passive_wordfile")
30+
31+# do the thing; two options
32+# "": stdinpaste
33+# -f: read from file
34+readfile() {
35+	inputfile=$(gum file) || die "no file supplied"
36+	gum_echo "passive voice found:"
37+	grep -E -n -i --color "\\b(am|are|were|being|is|been|was|be)\ \\b[ ]*(\w+ed|($words))\\b" "$inputfile"
38+}
39 
40-# print help if no args
41-if [[ "$#" -eq 0 ]]; then
42-	usage_help
43-fi
44+stdinpaste() {
45+	inputtext=$(gum write --header "paste text here") || die "no text supplied"
46+	gum_echo "passive voice found:"
47+	echo "$inputtext" | grep -E -n -i --color "\\b(am|are|were|being|is|been|was|be)\ \\b[ ]*(\w+ed|($words))\\b"
48+}
49 
50-# do the thing
51-gum_echo "weasel words found:"
52-grep -E -n -i --color "\\b(am|are|were|being|is|been|was|be)\ \\b[ ]*(\w+ed|($words))\\b" "$*"
53+# run script
54+case "$1" in
55+	"") stdinpaste;;
56+	"-f") readfile;;
57+	"-h") usage_help;;
58+esac
+26, -13
 1@@ -6,13 +6,13 @@
 2 # https://matt.might.net/articles/shell-scripts-for-passive-voice-weasel-words-duplicates/
 3 
 4 # vars
 5-weasel_word_dir="$HOME/.config/wordfiles"
 6-weasel_word_file="$weasel_word_dir/weasel"
 7+weasel_worddir="$HOME/.config/wordfiles"
 8+weasel_wordfile="$weasel_worddir/weasel"
 9 
10 # basic functions
11 usage_help() {
12-	echo "Usage: weasel [FILE]"
13-	exit 1
14+	echo "Usage: weasel [OPTIONS]"
15+	echo "Options: -f | -h"
16 }
17 
18 gum_echo() {
19@@ -26,17 +26,30 @@ die() {
20 
21 # check if word file exists
22 wordfile_check() {
23-	[[ -f "$weasel_word_file" ]] || die "weasel word file does not exist"
24+	[[ -f "$weasel_wordfile" ]] || die "weasel word file does not exist"
25 }
26 
27 # cat the word file into a var
28-words=$(wordfile_check && cat "$weasel_word_file")
29+words=$(wordfile_check && cat "$weasel_wordfile")
30+
31+# do the thing; two options
32+# "": stdinpaste
33+# -f: read from file
34+readfile() {
35+	inputfile=$(gum file) || die "no file supplied"
36+	gum_echo "weasel words found:"
37+	grep -E -n -i --color "\\b(am|are|were|being|is|been|was|be)\ \\b[ ]*(\w+ed|($words))\\b" "$inputfile"
38+}
39 
40-# print help if no args
41-if [[ "$#" -eq 0 ]]; then
42-	usage_help
43-fi
44+stdinpaste() {
45+	inputtext=$(gum write --header "paste text here") || die "no text supplied"
46+	gum_echo "weasel words found:"
47+	echo "$inputtext" | grep -E -n -i --color "\\b(am|are|were|being|is|been|was|be)\ \\b[ ]*(\w+ed|($words))\\b"
48+}
49 
50-# do the thing
51-gum_echo "weasel words found:"
52-grep -E -i -n --color "\\b($words)\\b" "$*"
53+# run script
54+case "$1" in
55+	"") stdinpaste;;
56+	"-f") readfile;;
57+	"-h") usage_help;;
58+esac