How I write posts on prose.sh - Part 1

· cuhadar.log

Powershell helper for prose.sh that generates the frontmatter and slug

Intro #

Creating a new post on prose.sh is already as simple as writing Markdown and running scp.
I wanted to shave off the last thirty seconds of boiler-plate, so I wrote a one-file PowerShell script called initprose.ps1.

What it does #

  1. Prompts for title, description, and comma-separated tags.
  2. Auto-fills the date, slug, and sensible defaults (draft: true, toc: false, etc.).
  3. Creates <slug>.md in the current directory.
  4. Prints the exact scp command you’ll need after editing.

The script #

 1# initprose.ps1
 2# -----------------------------------------
 3# Creates a prose.sh post
 4# -----------------------------------------
 5$today = Get-Date -Format "yyyy-MM-dd"
 6$title = Read-Host -Prompt "Enter the post title"
 7$description = Read-Host -Prompt "Enter the post description"
 8$image = "og.png"
 9
10$tagsInput = Read-Host -Prompt "Enter tags (comma separated)"
11$tagsArray = $tagsInput -replace '\s', '' | Where-Object { $_ }
12$tagsLine = "tags: [" + ($tagsArray -join ', ') + "]"
13
14$slug = Read-Host -Prompt "Enter slug (lowercase, hyphens, no extension)"
15$filepath = "$slug.md"
16
17$lines = @(
18    "---"
19    "title: $title"
20    "description: $description"
21    "date: $today"
22    $tagsLine
23    "image: $image"
24    "card: summary"
25    "draft: true"
26    "toc: false"
27    "---"
28    ""
29    "Body content goes here..."
30)
31
32Set-Content -Path $filepath -Value $lines -Encoding utf8
33
34Write-Host "Post created: $filepath"
35Write-Host "After editing, run: scp $slug.md prose.sh:/"

How I use it #

(You might want to save it as an alias to your Powershell $PROFILE but I'm skipping that part)

  1. Open my local prose folder with Visual Studio Code.
  2. Create new terminal and run .\initprose.ps1
  3. Answer prompts.
  4. Run code my-new-post.md and edit the generated file, change draft: true -> draft: false when ready.
  5. scp my-new-post.md prose.sh:/

That’s it. no YAML typos, no forgotten dates and reminder for scp command 🥳.

Ideas for next steps:

On Part 2, I will explain how I configured SSH (and therefore scp and rysnc) on my terminal to use the Bitwarden's SSH Agent.

Happy writing!

last updated: