Improving links script with Claude

Couple of helpful uses for LLM this week.
I have a script called “add-link” that prompts for link title, date, tags, then opens markdown file for me to edit, and saves it to git when I save the file.
I had previously been creating the files manually so this had been pretty useful.
But it still became a chore when I had a bunch of links from my phone that I wanted to work through.

I wanted to remove the (small) extra effort of typing ./add-link <url> then having to fix the date - usually I was adding links from over a few days.

Used this prompt and pasted my existing script at the end:

modify this script to run in a loop. Initially it prompts for an end date and a total number of links. If total is less that 8 it uses the 4 days leading up to the end date and goes from recent to old, otherwise the week leading up to it, starting on the first day.

Each cycle of the loop, prompt for a link first, then try getting the title from either the first

attribute, the in the response, or the url slug if neither of those are found. Use this improvement for parsing the h1 and title: grep -oP ‘<h1[^>]*>\K(.+?)(?=</h1>)’ | head -n 1.</p> <p>There should be a “Content?” Y/n option which defaults to Y, and opens vim, otherwise just git add and move onto the next file. When opening vim it should put the cursor at the end of the file</p> </blockquote> <p>The grep in there came after the first attempt failed to parse titles (my original script didn’t work for this).<br> So I pasted in the blob of html it returned and said “make h1 and title tag detection work for this markup” and it fixed it.</p> </article> </main> <footer class="site-footer"> <h3>Contact</h3> <span>Email: <b><a href="mailto:hi@psimyn.com">hi (at) psimyn dot com</a></b></span> <a href="https://github.com/psimyn"> <span>GitHub</span> </a> <a href="https://soundcloud.com/psimyn/">Soundcloud</a> <a href="https://codepen.io/psimyn"> <span>Codepen</span> </a> <a href="https://twitter.com/psimyn"> <span>Twitter</span> </a> </footer> <!-- <script src="/js/instantclick.min.js" data-no-instant></script> --> <!-- <script data-no-instant>InstantClick.init();</script> --> </body> <script>if (location.search === '?vert') { document.body.classList.add('vert') }</script> </html>