Skip to main content
  1. Today I Learned (TIL)/

Creating a TIL from the command line

·110 words·1 min·

TIL: I can scaffold a new TIL and open it in VSCodium with a small bash script that wraps Jekyll Compose.

#!/usr/bin/env bash

SITE_DIR="$HOME/<Site Directory...>" # Replace with the path to your site
# Take the first command line argument as the title
TITLE="$1"
# Change directory to the site directory
cd "$SITE_DIR" || exit
# Compose a new TIL
NEW_FILE_PATH=$(bundle exec jekyll compose "$TITLE" --collection='til' | grep -o '_til/.*')
# Open the newly created file
code "$SITE_DIR/$NEW_FILE_PATH"
# Start server
bundle exec jekyll s --livereload

Of course, I added it to a local bin directory in my PATH, so I can run the til '<Title...>' command from any location.

Chandler Thompson
Author
Chandler Thompson
I lead engineering teams and coach the people who run them. This is where I write down what actually worked.

Related