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
......@@ -8,3 +8,4 @@ colors {
88 unread purple
99 prompt green
1010 }
11+spell-check true
+26, -13
......@@ -6,13 +6,13 @@
66 # https://matt.might.net/articles/shell-scripts-for-passive-voice-weasel-words-duplicates/
77
88 # vars
9-passive_word_dir="$HOME/.config/wordfiles"
10-passive_word_file="$passive_word_dir/passive"
9+passive_worddir="$HOME/.config/wordfiles"
10+passive_wordfile="$passive_worddir/passive"
1111
1212 # basic functions
1313 usage_help() {
14- echo "Usage: passive [FILE]"
15- exit 1
14+ echo "Usage: passive [OPTIONS]"
15+ echo "Options: -f | -h"
1616 }
1717
1818 gum_echo() {
......@@ -26,17 +26,30 @@ die() {
2626
2727 # check if word file exists
2828 wordfile_check() {
29- [[ -f "$passive_word_file" ]] || die "passive word file does not exist"
29+ [[ -f "$passive_wordfile" ]] || die "passive word file does not exist"
3030 }
3131
3232 # cat the word file into a var
33-words=$(wordfile_check && cat "$passive_word_file")
33+words=$(wordfile_check && cat "$passive_wordfile")
3434
35-# print help if no args
36-if [[ "$#" -eq 0 ]]; then
37- usage_help
38-fi
35+# do the thing; two options
36+# "": stdinpaste
37+# -f: read from file
38+readfile() {
39+ inputfile=$(gum file) || die "no file supplied"
40+ gum_echo "passive voice found:"
41+ grep -E -n -i --color "\\b(am|are|were|being|is|been|was|be)\ \\b[ ]*(\w+ed|($words))\\b" "$inputfile"
42+}
3943
40-# do the thing
41-gum_echo "weasel words found:"
42-grep -E -n -i --color "\\b(am|are|were|being|is|been|was|be)\ \\b[ ]*(\w+ed|($words))\\b" "$*"
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+# run script
51+case "$1" in
52+ "") stdinpaste;;
53+ "-f") readfile;;
54+ "-h") usage_help;;
55+esac
+26, -13
......@@ -6,13 +6,13 @@
66 # https://matt.might.net/articles/shell-scripts-for-passive-voice-weasel-words-duplicates/
77
88 # vars
9-weasel_word_dir="$HOME/.config/wordfiles"
10-weasel_word_file="$weasel_word_dir/weasel"
9+weasel_worddir="$HOME/.config/wordfiles"
10+weasel_wordfile="$weasel_worddir/weasel"
1111
1212 # basic functions
1313 usage_help() {
14- echo "Usage: weasel [FILE]"
15- exit 1
14+ echo "Usage: weasel [OPTIONS]"
15+ echo "Options: -f | -h"
1616 }
1717
1818 gum_echo() {
......@@ -26,17 +26,30 @@ die() {
2626
2727 # check if word file exists
2828 wordfile_check() {
29- [[ -f "$weasel_word_file" ]] || die "weasel word file does not exist"
29+ [[ -f "$weasel_wordfile" ]] || die "weasel word file does not exist"
3030 }
3131
3232 # cat the word file into a var
33-words=$(wordfile_check && cat "$weasel_word_file")
33+words=$(wordfile_check && cat "$weasel_wordfile")
3434
35-# print help if no args
36-if [[ "$#" -eq 0 ]]; then
37- usage_help
38-fi
35+# do the thing; two options
36+# "": stdinpaste
37+# -f: read from file
38+readfile() {
39+ inputfile=$(gum file) || die "no file supplied"
40+ gum_echo "weasel words found:"
41+ grep -E -n -i --color "\\b(am|are|were|being|is|been|was|be)\ \\b[ ]*(\w+ed|($words))\\b" "$inputfile"
42+}
3943
40-# do the thing
41-gum_echo "weasel words found:"
42-grep -E -i -n --color "\\b($words)\\b" "$*"
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+# run script
51+case "$1" in
52+ "") stdinpaste;;
53+ "-f") readfile;;
54+ "-h") usage_help;;
55+esac