Creating Custom Actions

Learn how to create your own custom right-click actions in Power Menu using shell scripts.

Overview

In addition to its built-in actions, Power Menu lets you create your own custom actions that appear in the Finder right-click menu. Custom actions are powered by shell scripts, giving you full flexibility to automate file operations, run commands, and build workflows tailored to your needs.

How to Create a Custom Action

  1. Open the Power Menu app.
  2. Go to the Manage Actions screen.
  3. Click the + icon next to the Actions List title.
  4. Select Run a Custom Script from the menu.

Writing Your Script

When creating a custom action, you will need to provide a shell script that Power Menu will execute when the action is triggered. Custom actions require basic Bash programming knowledge.

How Files Are Passed to Your Script

Power Menu passes the selected files as an array of arguments to your script. You can access them in two ways:

  • "$@" -- Accesses the complete array of all selected files. Use this when your script should handle multiple files at once.
  • "$1", "$2", "$3" -- Accesses individual files by position. Use "$1" for the first selected file, "$2" for the second, and so on.

Always wrap these in double quotes to handle file paths that contain spaces.

Example: Open a File in a Specific App

open -a "Visual Studio Code" "$@"

Opens the selected file(s) in Visual Studio Code.

Example: Create a ZIP Archive

zip -r "${@}.zip" "$@"

Creates a ZIP archive of the selected file or folder.

Example: Copy File Paths to Clipboard

#!/bin/bash
function join_by { local IFS="$1"; shift; echo "$*"; }

join_by $'\n' "$@" | pbcopy

Copies the paths of all selected files to your clipboard, each on a separate line. The join_by function handles file names that contain spaces correctly.

Example: Open Terminal at Folder

open -a Terminal "$1"

Opens a new Terminal window at the selected folder's location.

Viewing Built-in Script Examples

You can view the scripts used by Power Menu's built-in actions for reference:

  1. Locate Power Menu.app in your Applications folder.
  2. Right-click it and select Show Package Contents.
  3. Navigate to Contents > Resources > Default Scripts.

These built-in scripts are a useful reference when writing your own custom actions.

Limitations

Power Menu does not currently support displaying any output produced by an action. Your scripts should perform their work silently or use macOS notifications (via osascript) if you need feedback.

Tips for Custom Actions

  • Test your scripts in Terminal before adding them to Power Menu to make sure they work as expected.
  • Custom actions appear alongside built-in actions in the right-click menu and can be toggled on or off just like any other action.
  • You can create as many custom actions as you need.

If you need any help with custom actions, please contact us.