Power Menu Custom Action Documentation
REQUIRED — Knowledge of how to program in Bash. is required to create a custom action.
What is a custom action, and what can it do?
A custom action is a script that runs on a specified list of files and can chose to interact with them or perform another action. Some examples of some custom actions are:
- New Terminal Window Here
- This action reads the selected folder and opens a new Terminal Window at that location.
- Show/hide hidden files in Finder
- This action runs a script to show and hide the hidden files in Finder.
- Copy paths to clipboard
- This action copies the selected list of files to the users clipboard.
Getting started
Create a custom action
You can create a custom action by performing the following steps:
- Open Power Menu
- Click the ‘Manage Actions’ section in the preferences
- Click the + button in the ‘Actions List’ table
- Click the ‘Run Custom Script’ option
- A new blank custom action will be created
What information is passed to the action?
The action is ran with a array of files are the arguments. You can access the array of files by using the "%@"
variable in your script. Or you can access a specific item in the array by using the "$1"
, "$2"
, "$3"
, etc variables. An couple examples of how the bundled scripts interact with this information is:
Copy paths to clipboard
This action reads the array of files using the "%@"
variable, then splits each item onto a new line.
#!/bin/bash
function join_by { local IFS="$1"; shift; echo "$*"; }
join_by $'\n' "$@" | pbcopy
New Terminal Window Here
This action reads the first item in the array and opens a new Terminal window at that location.
open -a Terminal "$1"
Does a Power Menu action support output?
Power Menu does not currently support displaying of any output that is produced by an action. This is something that may come in a later version.
Are there anymore examples?
You can view a list of a number of custom scripts that are included in Power Menu by doing the following:
- Locate Power Menu.app in Finder
- Right Click it
- Click the ‘Show Package Contents’ option
- Navigate to
Contents > Resources > Default Scripts
A list of some of the actions that appear in Power Menu will be listed. Unfortunately not all the actions are listed here since some of the action’s are handled by the app itself.