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 #
- Prompts for title, description, and comma-separated tags.
- Auto-fills the date, slug, and sensible defaults (
draft: true
,toc: false
, etc.). - Creates
<slug>.md
in the current directory. - 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)
- Open my local prose folder with Visual Studio Code.
- Create new terminal and run
.\initprose.ps1
- Answer prompts.
- Run
code my-new-post.md
and edit the generated file, changedraft: true
->draft: false
when ready. 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:
- Auto-generate the OG Image with Pillow or ImageMagick (or even using this Apify Actor: og-image-generator ).
- Hook a trigger to auto upload assets to Backblaze B2 bucket.
- Complicate things to further contrast with prose.sh philosophy :D
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: