我想获取最顶层终端选项卡/窗口的当前目录(通过 AppleScript 或其他方式,这并不重要)。我怎样才能做到这一点?
另一个解决方案。
get_foregroundterminal_curdir_fast.scpt:
tell application "Terminal"
do shell script "lsof -a -p `lsof -a -c bash -u $USER -d 0 -n | tail -n +2 | awk '{if($NF==\"" & (tty of front tab of front window) & "\"){print $2}}'` -d cwd -n | tail -n +2 | awk '{print $NF}'"
end tell
I use lsof
本身获取相应终端窗口的 bash shell 的 PID。这比使用快得多fuser
(毫秒与秒)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)