Last active
September 11, 2026 20:58
-
-
Save ramirez7/626b9466f49dcb7d1b3df53e871536d5 to your computer and use it in GitHub Desktop.
stfu.sh - Google-Search-AI-mode-coded script to remove all new comments from a git diff. Run it after your AI codes to shut it up.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env nix-shell | |
| #!nix-shell -i bash -p gnused perl git | |
| # Discover all unstaged Haskell and TypeScript files with modifications | |
| mapfile -t FILES < <(git diff --name-only | grep -E '\.(hs|ts)$') | |
| if [ ${#FILES[@]} -eq 0 ]; then | |
| echo "No modified Haskell (.hs) or TypeScript (.ts) files found in git status." | |
| exit 0 | |
| fi | |
| echo "Found ${#FILES[@]} modified source file(s). Processing..." | |
| for FILE in "${FILES[@]}"; do | |
| [ ! -f "$FILE" ] && continue | |
| # Determine file extension and set regex patterns accordingly | |
| EXT="${FILE##*.}" | |
| if [ "$EXT" = "hs" ]; then | |
| echo " -> Stripping new Haskell comments from: $FILE" | |
| # Match single-line (--) and multi-line ({- ... -}) | |
| COMMENT_REGEX='(--.*|{-[\s\S]*?-})' | |
| elif [ "$EXT" = "ts" ]; then | |
| echo " -> Stripping new TypeScript comments from: $FILE" | |
| # Match single-line (//) and multi-line (/* ... */) | |
| COMMENT_REGEX='(\/\/.*|\/\*[\s\S]*?\*\/)' | |
| else | |
| continue | |
| fi | |
| export COMMENT_REGEX | |
| # 1. Extract and erase the language-specific comment blocks precisely | |
| git diff -U0 "$FILE" | grep '^[+][^+]' | gsed 's/^[+]//' | perl -0777 -pe ' | |
| my $regex = $ENV{COMMENT_REGEX}; | |
| @comments = m/$regex/g; | |
| $_ = join("\n", @comments); | |
| ' | while IFS= read -r comment_chunk || [ -n "$comment_chunk" ]; do | |
| [ -z "$comment_chunk" ] && continue | |
| export COMMENT_CHUNK="$comment_chunk" | |
| perl -i -0777 -pe ' | |
| my $chunk = $ENV{COMMENT_CHUNK}; | |
| s/\Q$chunk\E\n?//g; | |
| ' "$FILE" | |
| done | |
| # 2. Collapse consecutive redundant blank lines to clean up voids left by the diff | |
| perl -i -0777 -pe 's/\n{3,}/\n\n/g' "$FILE" | |
| # 3. Clean up any trailing blank spaces at the very end of the file | |
| perl -i -0777 -pe 's/\n+\z/\n/' "$FILE" | |
| done | |
| echo "Done! All newly added comments have been completely stripped." |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
seems to work