Posted on :: Tags: , , ,

I wanted to get the number of word changes between commits in my blogs. I asked for a git diff based nushell pipeline from Gemini:

Gemini proposed this:

git diff --word-diff=plain -- "*.md" | rg -o '\{\+(.*?)\+\}' | str replace -r '\{\+|\+\}' '' | str join " " | str words | length
NUSHELL

What I ended up doing:

git diff --word-diff=plain -- "*.md" | rg -o '\{\+(.*?)\+\}' | str replace -a "{+" "" | str replace -a "+}" "" | str replace -a ' ' "\n" | lines | length
NUSHELL

I notice LLMs tend to err on the side of complexity. I don’t know if this is due to their training to spit as many tokens as possible but using regular expressions when a simple single replace may suffice is a good sign that they may be adding more complexity than necessary.