Replicate $PATH From Your Terminal.app Environment to Keyboard Maestro

Hey Folks,

Some folks struggle when they find out that the default $PATH from their Terminal.app environment is NOT replicated in Keyboard Maestro.

There's a simple way to work around this, and that is to add a variable named ENV_PATH to Keyboard Maestro and give it the same path you can find in your Terminal by using the command echo $PATH.

I have automated this process in the appended macro.

-Chris


NOTE:

If using macOS Ventura or later you'll need to change “Preferences” to “Settings” in the Select or Show a Menu Item action in the macro.


Download: Make ENV_PATH Variable in Keyboard Maestro Using the Terminal v1.00.kmmacros (12 KB)

Macro Image


9 Likes

image


Hey Folks,

Here's a pretty painless way to to compare your macOS Terminal and Keyboard Maestro $PATH strings.

  • KM creates it's own environment for shell scripts it is often at variance with the Terminal environment.
  • The user is responsible for managing these differences.
  • Hopefully this tool will help with that.

-Chris


Download: Compare Terminal & Keyboard Maestro $PATH Strings v1.00.kmmacros (14 KB)

Macro-Image

Keyboard Maestro Export

Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 10.14.6
  • Keyboard Maestro v10.2

3 Likes

Greetings- Can you suggest how to revise this to work with zsh?

Try adding a zsh shebang line to the execute shell script action.

#!/usr/bin/env zsh

Let me know if that works.