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:
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:
Get the plugin and examples on GitHub.
🔒
Premium Content
Don't forget about the rest!