我想知道如何使用Applescript在iTerm中获取当前会话的当前位置。
我试过各种各样的东西。这本字典对我来说很难理解。
这是我最近的尝试
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会话当前的位置:/Users/SuperCoolGuy/Desktop
发布于 2014-07-31 19:23:14
这很难看..。
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)发布于 2018-12-07 19:00:44
如果有人无意中发现了这个问题,现在壳集成还有另一个选择。使用它,您可以使用iTerm定义的变量session.path访问iTerm中的路径。
activate application "iTerm"
tell application "iTerm"
tell current session of current window
set myTerm to (variable named "session.path")
write text "echo this is the current path: " & myTerm
end tell
end tell发布于 2014-07-31 18:40:43
这些信息目前无法通过iTerm的AppleScript接口获得。会话对象唯一公开的属性与在其中运行的内容(与其可视化外观相反)是contents和tty,而这些属性不是您在这里要寻找的。
https://stackoverflow.com/questions/25051288
复制相似问题