Exporting shell environment variables from Execute Shell Script


#1

The Execute Shell Script action runs in non-interactive mode which means none of the configuration scripts are invoked. Even if I call the configuration file from the first line of my action it doesn’t work. Is there any way at all I can automate the setting up of variables so that I don’t have to start each Execute Shell Script action with three long export commands?


#2

Hey @Sleepy,

How exactly are you doing that?

You can set environment variables in Keyboard Maestro’s Variables preference panel.

See ⇢ “Setting the ENV_PATH Keyboard Maestro Variable” on the wiki:

https://wiki.keyboardmaestro.com/action/Execute_a_Shell_Script

If you really want to load your config file then you can do something like this in your scripts:

source ~/.bashrc

-Chris


#3

I did read that wiki page prior to writing my post but didn’t quite grasp the part that I needed to understand. But since you redirected me to it I assumed it would help me and I reread it and indeed it can be used to set any variable not just the PATH variable.

I used to be a UNIX admin (not a very good one) and even then I would forget about the source command. The fact that you put the source command in front of the line of text I had will probably fix that problem. But using the preference panel is probably a better idea for me, thanks!!