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
+26,
-13
| ... | ... | @@ -6,13 +6,13 @@ | |
| 6 | 6 | # https://matt.might.net/articles/shell-scripts-for-passive-voice-weasel-words-duplicates/ | |
| 7 | 7 | ||
| 8 | 8 | # 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" | |
| 11 | 11 | ||
| 12 | 12 | # basic functions | |
| 13 | 13 | usage_help() { | |
| 14 | - | echo "Usage: passive [FILE]" | |
| 15 | - | exit 1 | |
| 14 | + | echo "Usage: passive [OPTIONS]" | |
| 15 | + | echo "Options: -f | -h" | |
| 16 | 16 | } | |
| 17 | 17 | ||
| 18 | 18 | gum_echo() { |
| ... | ... | @@ -26,17 +26,30 @@ die() { | |
| 26 | 26 | ||
| 27 | 27 | # check if word file exists | |
| 28 | 28 | 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" | |
| 30 | 30 | } | |
| 31 | 31 | ||
| 32 | 32 | # cat the word file into a var | |
| 33 | - | words=$(wordfile_check && cat "$passive_word_file") | |
| 33 | + | words=$(wordfile_check && cat "$passive_wordfile") | |
| 34 | 34 | ||
| 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 | + | } | |
| 39 | 43 | ||
| 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 @@ | |
| 6 | 6 | # https://matt.might.net/articles/shell-scripts-for-passive-voice-weasel-words-duplicates/ | |
| 7 | 7 | ||
| 8 | 8 | # 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" | |
| 11 | 11 | ||
| 12 | 12 | # basic functions | |
| 13 | 13 | usage_help() { | |
| 14 | - | echo "Usage: weasel [FILE]" | |
| 15 | - | exit 1 | |
| 14 | + | echo "Usage: weasel [OPTIONS]" | |
| 15 | + | echo "Options: -f | -h" | |
| 16 | 16 | } | |
| 17 | 17 | ||
| 18 | 18 | gum_echo() { |
| ... | ... | @@ -26,17 +26,30 @@ die() { | |
| 26 | 26 | ||
| 27 | 27 | # check if word file exists | |
| 28 | 28 | 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" | |
| 30 | 30 | } | |
| 31 | 31 | ||
| 32 | 32 | # cat the word file into a var | |
| 33 | - | words=$(wordfile_check && cat "$weasel_word_file") | |
| 33 | + | words=$(wordfile_check && cat "$weasel_wordfile") | |
| 34 | 34 | ||
| 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 | + | } | |
| 39 | 43 | ||
| 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 |