Keyboard Maestro执行Shell脚本默认环境变量

2024-01-13
#Unix #Automation

Keyboard Maestro 在执行 Shell 脚本 (Execute a Shell Script) 时,默认的环境变量为:

/usr/bin:/bin:/usr/sbin:/sbin

有三种解决方案1

  1. 使用工具或文件的显式完整路径 (Use an explicit, full path to the tool or file.)

  2. 在每个执行 Shell 脚本操作中设置 $PATH 环境变量 (Set the $PATH environment variable within each Execute Shell Script action. )

  3. 在执行 Shell 脚本操作之前设置 ENV_PATH Keyboard Maestro 变量 (Set ENV_PATH Keyboard Maestro variable prior to the Execute Shell Script Action.)

比如,显式完整路径: /opt/homebrew/bin/node

where node

/opt/homebrew/bin/node

在执行 node 时,在 Shell 脚本第一行加入:

PATH=$PATH:/opt/homebrew/bin/

这样,就可以直接用 node

延伸阅读

  1. action:Execute a Shell Script [Keyboard Maestro Wiki]