My Favourite Use Case for AI
AI seems to have weaved its way into most software developers daily life, whether it's conversational advice, better autocomplete, or even just plain code generation. However, the use-case that I really enjoy is when it can speed-run boring tasks for me.
I don't use AI that much when programming. For me, I prefer it to complete little side quests for me than to get involved in my main work.
My recent use case was for this blog. I change up how I write and publish posts quite regularly, depending on the computer, and tools I want to use. So while I'm using Omarchy on my new Framework laptop, I'm more terminal-heavy than before. So ideally, I'd be able to run a quick shell script on my laptop, and then jump into writing a blog post.
So I gave Perplexity my idea, and then let it come up with a simple bash script to do that very job for me.
#!/usr/bin/env bash
# Exit if no title is provided
if [ -z "$1" ]; then
echo "Usage: $0 \"Post Title\""
exit 1
fi
# Get current date parts
YEAR=$(date +%Y)
MONTH=$(date +%m)
DATE=$(date +%Y-%m-%d)
# Input title
TITLE="$1"
# Create slug (snake_case for filename, kebab-case for permalink)
SLUG_SNAKE=$(echo "$TITLE" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/_/g; s/^_|_$//g')
SLUG_KEBAB=$(echo "$TITLE" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g; s/^-|-$//g')
# Directory structure
DIR="posts/$YEAR/$MONTH"
mkdir -p "$DIR"
# Filename
FILE="$DIR/$SLUG_SNAKE.md"
# If file already exists, don’t overwrite
if [ -f "$FILE" ]; then
echo "File already exists: $FILE"
nvim "$FILE"
exit 0
fi
# Write frontmatter to file
cat >"$FILE" <<EOF
---
title: $TITLE
date: $DATE
tags:
- post
layout: layouts/post
permalink: $SLUG_KEBAB/
---
EOF
# Open in Neovim
nvim +"normal Go" "$FILE"
It does the following:
- Takes in a single parameter, which is the blog post title.
- Creates any required directories.
- It uses that title in snake case for the filename, and creates a file.
- It uses the title again, but in kebab case for the permalink.
- Generates the rest of the frontmatter required for a standard post.
- Opens the new file in Neovim.
I'm sure I could have written this script myself, but I didn't want to. This is the sort of task that I put off for weeks, and maybe never get around to doing it. So being able to get AI to do this for me, makes my life much easier.
I only just thought about this, but I should probably make use of my own Text Case CLI tool, and also format the title properly. That can be in the next version.