【问题标题】:Can I check which application opened .zshrc?我可以检查哪个应用程序打开了 .zshrc 吗?
【发布时间】:2021-02-09 09:25:50
【问题描述】:

我使用的是 Macbook pro Big Sur。 每次我打开 Atom(文件编辑器)时,它都会执行 .zshrc 文件

如果由新终端或 Atom(或其他应用程序)打开,我可以设置一个 IF 语句来执行特定的行

谢谢

【问题讨论】:

  • 是由启动 Atom 的 shell 执行,还是由 Atom 启动读取文件的 shell?

标签: macos shell atom-editor


【解决方案1】:

这样做的方法是检查 PPID 以查看它是否是登录。应用程序没有它。
例如:

ps auxwww | grep ${PPID} | grep login
RES=$?

if [[ $RES == 0  ]]; then
     <...>
fi

【讨论】:

    猜你喜欢
    • 2016-03-12
    • 1970-01-01
    • 2021-08-20
    • 1970-01-01
    • 2016-07-17
    • 2013-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多