Best Method to Set ENV_PATH Variable for Multiple Computers and Scripts?

Here’s how I came up with an ENV_PATH to work on all my computers:

  1. On each computer, run

    echo $PATH | sed 's/:/\n/g'
    

    This will give you list of the directories that are searched for executables on that computer. The sed part isn’t necessary, but it breaks the list up onto separate lines, which makes the list easier to read.

  2. Looking at lists from all your computers, assemble a new list that is a superset of all the directories. In this list, the directories must be separated by colons, not newlines.

  3. Save this new list as ENV_PATH in Keyboard Maestro on all your computers.

The order of the list matters, because the directories are searched in that order. So if you’ve installed a version of, say, Perl that’s more recent than the one that comes with the Mac, you’ll want to make sure the directory it’s in comes before /usr/bin.

Don’t worry if the list contains directories that don’t exist on all the computers. When the system encounters a non-existing directory, it just moves on to the next one in the list.

7 Likes