This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
action:Execute_a_Shell_Script [2021/10/18 03:51] peternlewis [Path in Shell Scripts] |
action:Execute_a_Shell_Script [2023/09/12 22:59] peternlewis [Using Keyboard Maestro Variables] |
||
---|---|---|---|
Line 41: | Line 41: | ||
==== Using Keyboard Maestro Variables ==== | ==== Using Keyboard Maestro Variables ==== | ||
- | === Most Languages like bash, perl, ruby === | + | Keyboard Maestro variables are included in the environment of the script, with the prefix `KMVAR_` and spaces in the name replaced with underscores (‗), |
+ | |||
+ | By default, all variables are included, but you can select No Variables, or specific variables as desired using the popup menu next to the script (v11.0+). | ||
+ | |||
+ | === Most Shell Languages like bash === | ||
In your script, use this format $KMVAR‗*VARIABLE‗NAME* where *VARIABLE‗NAME* is the name of your Keyboard Maestro Variable, but with spaces in the name replaced with underscores (‗). | In your script, use this format $KMVAR‗*VARIABLE‗NAME* where *VARIABLE‗NAME* is the name of your Keyboard Maestro Variable, but with spaces in the name replaced with underscores (‗). | ||
Line 252: | Line 256: | ||
For example, if you want to use [[https://www.perl.org/ | Perl]] with a custom library search path in the Execute a Shell Script action, you can also create a Keyboard Maestro variable `ENV_PERL5LIB` that will set the [[http://perldoc.perl.org/perlrun.html#ENVIRONMENT|PERL5LIB environment variable]]. | For example, if you want to use [[https://www.perl.org/ | Perl]] with a custom library search path in the Execute a Shell Script action, you can also create a Keyboard Maestro variable `ENV_PERL5LIB` that will set the [[http://perldoc.perl.org/perlrun.html#ENVIRONMENT|PERL5LIB environment variable]]. | ||
+ | |||
+ | ===== Working Directory ===== | ||
+ | |||
+ | The working directory for any executed scripts will be set from the Keyboard Maestro `ENV_PWD` directory (v10.0+), or default to the root directory (`/`). | ||
+ | |||
===== Execute Script From Other Apps ===== | ===== Execute Script From Other Apps ===== |