MacOS – Add a custom terminal command to context menu in mac

macmacosservicesterminal

Is there a way to add a custom command when I right click a folder in mac? I have a global NPM module which I run like this from the terminal:

~ make-assets

The behaviour I want to achieve is that when I right click a folder ("Source_Sans_Pro" in this example) I would have a "Make assets" option that would run the "make-assets" command in the terminal in the correct folder.

Preferably, I would like to have it below 'Get Info' but in the services submenu is also OK.

mac context

Best Answer

You can easily add it to the Services menu by creating an Automator Workflow.

Here are the steps:

  1. Launch Automator.
  2. Choose "Service" for the type of document.
  3. Set the following two dropdowns to:Service receives selected "Folder" in "Finder"
  4. Drag the "Run Shell Script" action to the Workflow pane.
  5. Add your code and modify as appropriate.

Google is your friend if you're not familiar with Automator.

Related Question