gpt4 book ai didi

applescript - 获取 iTerm 位置 Applescript

转载 作者:行者123 更新时间:2023-12-04 03:28:41 29 4
gpt4 key购买 nike

我想知道如何使用 Applescript 在 iTerm 中获取当前 session 的当前位置。

我尝试了各种各样的事情。字典对我来说很难理解。

这是我最近的尝试

tell application "iTerm"
tell the current session of current terminal
set theSelection to attachment file name
display dialog theSelection
end tell

end tell

这产生的错误是:
error "iTerm got an error: Can’t get file name of current session of current terminal." number -1728 from file name of current session of current terminal

我只想要 iTerm session 当前所在的位置: /Users/SuperCoolGuy/Desktop

最佳答案

这是丑...

tell application "iTerm"
if not (exists terminal 1) then reopen
set mySession to current terminal's current session
tell mySession
write text "pwd"
set sessionContents to it's text
end tell
end tell

set myPath to paragraph -2 of (do shell script "grep . <<< " & quoted form of sessionContents)

关于applescript - 获取 iTerm 位置 Applescript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25051288/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com