The letter A styled as Alchemists logo. lchemists

Putin's War on Ukraine - Watch President Zelenskyy's speech and help Ukraine fight against the senseless cruelty of a dictator!

Published March 18, 2012 Updated March 7, 2023
Pennyworth Icon

Pennyworth

14.2.0

Pennyworth is a command line interface and the perfect companion to Alfred. With Pennyworth, you can unlock the full potential of the Ruby language by leveraging a modern version of Ruby through Alfred Workflows. Perfect for when you want to advance beyond the basic workflows Alfred provides by default.

Features

  • Adds Ruby support to Alfred.

  • Supports building advanced Workflows for personal augmentation.

Screencast

Requirements

While using a Ruby Version Manager is not a hard requirement, it is strongly encouraged since a version manager will give you the freedom to toggle between different Ruby versions since this gem has strict Ruby version requirements (especially in regards to using a modern version of Ruby).

All of the workflows, scripts, examples for this gem use Bash syntax. That said, if you are comfortable with translating Bash syntax to your shell syntax of choice, you can make this gem work in different shells too. That is beyond the scope of this document, though, so leave that exercise up to you.

Setup

To install, run:

gem install pennyworth

When using the --git_hub CLI option, you’ll want to supply your GitHub login and Personal Access Token with at least read access via the following environment variables:

GITHUB_API_LOGIN=
GITHUB_API_TOKEN=

You can configure these environment variables via direnv if using the CLI or through the Alfred Workflow Environment.

⚠️ When using Alfred Workflow environment variables, please ensure you check the Don’t Export option for these variables so you don’t expose your credentials when exporting/sharing workflows with others.

Usage

Command Line Interface (CLI)

From the command line, type pennyworth to view usage:

Pennyworth - A command line interface that augments Alfred workflows.

USAGE:
  -c, --config ACTION                      Manage gem configuration. Actions: edit || view.
      --encodings                          Render Alfred encodings script filter.
      --git_hub                            Render Alfred GitHub repositories script filter.
  -h, --help                               Show this message.
      --http_statuses                      Render Alfred HTTP statuses script filter.
      --ruby_gems                          Render Alfred RubyGems script filter.
      --standard_errors                    Render Alfred standard errors script filter.
      --system_errors                      Render Alfred system errors script filter.
      --system_signals                     Render Alfred system signals script filter.
      --text CONTENT                       Render Alfred text script filter.
  -v, --version                            Show gem version.

GITHUB OPTIONS:
      --organization [HANDLE]              Set organization. Default: "".
      --user [HANDLE]                      Set user. Default: "".

RUBYGEMS OPTIONS:
      --owner [HANDLE]                     Set owner. Default: "".

The following demonstrates how to use Pennyworth from the CLI or within an Alfred Script Filter:

pennyworth --config edit
pennyworth --config view

pennyworth --encodings

pennyworth --git_hub --organization alchemists
pennyworth --git_hub --user bkuhlmann

pennyworth --http_statuses
pennyworth --ruby_gems --owner bkuhlmann
pennyworth --standard_errors
pennyworth --system_errors
pennyworth --system_signals

pennyworth --text demo
pennyworth --text "An Example"

While the command line options are nice, the real power comes from using Pennyworth in conjunction with Alfred Script Filters. Without having Alfred wired up to consume the CLI output, you’ll only get a JSON in your console. To explain better, continue reading or skip ahead to the Workflows section.

Customization

This gem can be configured via a global configuration:

~/.config/pennyworth/configuration.yml

It can also be configured via XDG environment variables.

The default configuration is as follows:

:alfred:
  :preferences:
:inflections:
  - "Bkuhlmann": "bkuhlmann"
  - "Dry Auto Inject": "Dry AutoInject"
  - "Dry Cli": "Dry CLI"
  - "Flacsmith": "FLACsmith"
  - "Git Plus": "Git+"
  - "Http Fake": "HTTP Fake"
  - "Mac Os Config": "macOS Configuration"
  - "Mac Os": "MacOS"
  - "Pkce": "PKCE"
  - "Prawn Plus": "Prawn+"
  - "Rubocop Ast": "Rubocop AST"
  - "Rubocop Md": "Rubocop Markdown"
  - "Rubocop Rspec": "Rubocop RSpec"
  - "Tty Box": "TTY Box"
  - "Tty Color": "TTY Color"
  - "Tty Command": "TTY Command"
  - "Tty Config": "TTY Config"
  - "Tty Cursor": "TTY Cursor"
  - "Tty Editor": "TTY Editor"
  - "Tty File": "TTY File"
  - "Tty Font": "TTY Font"
  - "Tty Link": "TTY Link"
  - "Tty Logger": "TTY Logger"
  - "Tty Markdown": "TTY Markdown"
  - "Tty Option": "TTY Option"
  - "Tty Pager": "TTY Pager"
  - "Tty Pie": "TTY Pie"
  - "Tty Platform": "TTY Platform"
  - "Tty Progressbar": "TTY ProgressBar"
  - "Tty Prompt": "TTY Prompt"
  - "Tty Reader": "TTY Reader"
  - "Tty Screen": "TTY Screen"
  - "Tty Spinner": "TTY Spinner"
  - "Tty Table": "TTY Table"
  - "Tty Tree": "TTY Tree"
  - "Tty Which": "TTY Which"
  - "Xdg": "XDG"
:git_hub:
  :api_url: "https://api.github.com"
  :organization:
  :user:
:http:
  :statuses:
    :url: "https://developer.mozilla.org/docs/Web/HTTP/Status"
:ruby_gems:
  :api_url: "https://rubygems.org/api/v1"
  :owner:

Feel free to take this default configuration, modify, and save as your own custom configuration.yml.

Themes

Alchemists Theme

The above is shared as the Alchemists Alfred Theme which can be installed directly.

Workflows

Not all workflows require Pennyworth to run properly (see the Other section below for details). For the workflows that do require Pennyworth support, the following assumptions are made:

  1. Your Dotfiles are configured to use Bash and load your environment appropriately. Bash is not a hard requirement, though. You can use any shell you are comfortable with as long as you teach Alfred to load your development environment before running the Alfred Workflow.

  2. You have the latest version of Alfred, Ruby, and Pennyworth installed.

  3. You are using a Ruby Version Manager which ensures Ruby is on your load path. As mentioned in the Requirements section above, this is not a hard requirement so if you have the correct version of Ruby required by this gem on your path, that’ll work too.

With the above requirements in mind, the following sections document how to download and install all Pennyworth workflows that are compatible with Alfred. Should you want to tweak any of these workflows, you’d only need to edit an existing workflow or build your own with these settings:

Script Filter

Before diving into each workflow, I want to highlight that the following capabilities are available to all workflows depending on what kind of item is currently selected within the Alfred UI:

  • SHIFT or COMMAND + y will launch Quicklook for any URL based workflow.

  • ENTER or COMMAND + c will copy selections to clipboard (depends on context, though).

  • COMMAND + l will launch Large Type of current selection.

  • ENTER Will either copy selection to clipboard or launch URL in default web browser.

Alchemists

Alchemists Projects

Provides quick access to Alchemists resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Dry RB

Dry Gems

Provides quick access to Dry RB resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

RuboCop

Rubocop Projects

Provides quick access to RuboCop resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Ruby

Ruby workflow screenshot

Provides quick access to Ruby resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Other

The following workflows don’t require this gem to use but are provided for convenience in case they are of aid to your own productivity.

Acronyms

Acronyms workflow screenshot.

Expands acronyms so you can think and type in terms of an acronym but appear as if you typed out the full definition each time.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Alpine

Alpine Linux workflow screenshot.

Provides quick access to Alpine Linux resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Applications

Applications workflow screenshot.

Launches your engineering environment but can be tweaked to your preferences. Using Alfred in this manner ensures your machine boots quickly so you have more control over what is launched.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Bash

Bash workflow screenshot.

Provides quick access to Bash resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Bio

Bio workflow screenshot.

Provides biographical calculations and information.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Browsers

Browsers workflow screenshot.

Provides quick access to browser resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Bundler

Bundler workflow screenshot.

Provides quick access to Bundler related resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Circle CI

Circle CI workflow screenshot.

Provides quick access to Circle CI resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Crystal

Crystal workflow screenshot.

Provides quick access to Crystal resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

CSS

CSS workflow screenshot.

Provides quick access to CSS resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Docker

Docker workflow screenshot.

Provides quick access to Docker resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Elm

Elm workflow screenshot.

Provides quick access to Elm resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Farnam Street

Farnam Street workflow screenshot.

Provides quick access to Farnam Street resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Git

Git workflow screenshot.

Provides quick access to Git resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

GitHub

GitHub workflow screenshot.

Provides quick access to GitHub resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Hanami

Hanami workflow screenshot.

Provides quick access to the Hanami web framework.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

HTML

HTML workflow screenshot.

Provides quick access to the HTML language.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

HTMX

HTMX workflow screenshot.

Provides quick access to the HTMX JavaScript library.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Internet Protocol (IP)

IP workflow screenshot.

Provides quick access to IP tooling and resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Jitsi

Jitsi workflow screenshot.

Provides quick access to Jitsi resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

macOS

macOS workflow screenshot.

Provides quick access to macOS resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Rack

Rack workflow screenshot.

Provides quick access to Rack resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Roda

Roda workflow screenshot.

Provides quick access to the Roda web framework.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

ROM

ROM workflow screenshot.

Provides quick access to Ruby Object Mapper (ROM) resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

RSpec

RSpec workflow screenshot.

Provides quick access to RSpec resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Ruby on Rails

Ruby on Rails workflow screenshot.

Provides access to the Ruby on Rails web framework.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Search workflow screenshot.

Provides quick access to search resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Slack

Slack workflow screenshot.

Provides quick access to Slack resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

SSL

SSL workflow screenshot.

Provides quick access to SSL resources for the security conscious.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Terraform

Terraform workflow screenshot.

Provides quick access to Terraform resources.

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Text

Text workflow screenshot.

Provides general text manipulation utilities beyond the Pennyworth powered text macro which is part of the Ruby workflow (mentioned earlier).

  1. Download and double click to install.

  2. Click on Configure Workflow to view documentation.

Troubleshooting

  • Psych 4.0.0 has a bug which prevents loading of YAML configurations that use symbols as keys. If you get caught by this, please upgrade to Psych 4.0.1 for the fix.

  • When your Alfred Workflow yields no output, you might want to open the Alfred Debugger, rerun your workflow, and check for errors. You can also jump to the CLI and run Pennyworth directly.

  • If you get GitHub authorization errors, make sure you have defined the appropriate credentials (mentioned earlier) for both within your shell where you are running Pennyworth or within the Alfred Workflow environment.

Development

To contribute, run:

git clone https://github.com/bkuhlmann/pennyworth
cd pennyworth
bin/setup

You can also use the IRB console for direct access to all objects:

bin/console

Architecture

The following documents the workflow used to process all actions from Alfred.

Architecture Diagram

Tests

To test, run:

bin/rake

Credits