xxwhirlpool
·
2026-05-14
passive
1#!/usr/bin/env bash
2#
3# script to detect passive voice in a file
4#
5# inspired by the below blog post:
6# https://matt.might.net/articles/shell-scripts-for-passive-voice-weasel-words-duplicates/
7
8# vars
9passive_word_dir="$HOME/.config/wordfiles"
10passive_word_file="$passive_word_dir/passive"
11
12# basic functions
13usage_help() {
14 echo "Usage: passive [FILE]"
15 exit 1
16}
17
18gum_echo() {
19 gum style --foreground "#f4b8e4" "$@"
20}
21
22die() {
23 printf "%s\n" "$1"
24 exit 1
25}
26
27# check if word file exists
28wordfile_check() {
29 [[ -f "$passive_word_file" ]] || die "passive word file does not exist"
30}
31
32# cat the word file into a var
33words=$(wordfile_check && cat "$passive_word_file")
34
35# print help if no args
36if [[ "$#" -eq 0 ]]; then
37 usage_help
38fi
39
40# do the thing
41gum_echo "weasel words found:"
42grep -E -n -i --color "\\b(am|are|were|being|is|been|was|be)\ \\b[ ]*(\w+ed|($words))\\b" "$*"