I’ve published a tiny Jekyll plugin that makes terminal commands in posts runnable with a click (in iTerm, at least).

The iTerm tag plugin renders a fenced code block showing a command, and a “Run in iTerm” link that uses iTerm 2’s new(ish) command url scheme (iterm2:/command?c=COMMAND) to open the command in a confirmation box in iTerm, ready for immediate execution.

The plugin outputs fenced code blocks with language definitions, so whatever syntax highlighter your Jekyll blog uses can still appropriately highlight the code. The “Run in iTerm” link is given a little extra markup to make it easy to style.

Examples

If you’re running iTerm, click the link below the code blocks to open
the command in a confirmation dialog.

Short form:

[iterm "gem install ruby-progress"]

Renders:

[iterm “gem install ruby-progress”]

Key/value form (custom text, directory, language):

[iterm command:"python -m http.server" directory:"~/Sites/project" text:"iTerm: Start dev server" language:"console"]

That outputs a fenced code block with the command and a small “Run in iTerm” link/button that uses iTerm2’s URL scheme:

[iterm command:”python -m http.server” directory:”~/Sites/project” text:”iTerm: Start dev server” language:”console”]

Get the plugin and examples on GitHub.

[paywall “Don’t forget about the rest!”]

Don’t Forget

Just a reminder, there are a few other Jekyll Plugins in the repo that you might want to take a look at.

Availability
A plugin to mark content as beta or upcoming based on Sparkle appcast build numbers; provides [available X.X.X] and notification tags.
Countdown
Outputs markup for a client-side countdown timer (works with jq-timeTo).
Donation
Generates a PayPal donate button/form with configurable ID and text.
GifTag
Produces a poster-frame GIF element with on-click play/pause and optional ImageMagick poster generation.
GistTag
Fetches and caches Gists locally and highlights them with Pygments; includes cache controls.
HTML5Audio
Emits semantic HTML5 audio markup with MP3/OGG sources and optional figcaption.
KBDTag
Generates Apple-style keyboard shortcut markup, configurable for symbols or text with tags like [kbd cmd-shift-x].
OGTags
Captures a description block for use in OpenGraph/Twitter meta tags via [describe].
YouTube
Responsive YouTube embed tag that extracts IDs from URLs and outputs a responsive iframe wrapper.

[endpaywall]


Leave a Reply

Your email address will not be published. Required fields are marked *