dots


dots / config / .local / bin
xxwhirlpool  ·  2026-05-14

weasel

 1#!/usr/bin/env bash
 2#
 3# script to detect weasel words 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
 9weasel_word_dir="$HOME/.config/wordfiles"
10weasel_word_file="$weasel_word_dir/weasel"
11
12# basic functions
13usage_help() {
14	echo "Usage: weasel [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 "$weasel_word_file" ]] || die "weasel word file does not exist"
30}
31
32# cat the word file into a var
33words=$(wordfile_check && cat "$weasel_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 -i -n --color "\\b($words)\\b" "$*"