首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >获取iTerm位置Applescript

获取iTerm位置Applescript
EN

Stack Overflow用户
提问于 2014-07-31 05:15:44
回答 3查看 807关注 0票数 4

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

我试过各种各样的东西。这本字典对我来说很难理解。

这是我最近的尝试

代码语言:javascript
复制
tell application "iTerm"
        tell the current session of current terminal
            set theSelection to attachment file name
            display dialog theSelection
        end tell

    end tell

由此产生的错误是:

代码语言:javascript
复制
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

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-07-31 19:23:14

这很难看..。

代码语言:javascript
复制
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)
票数 4
EN

Stack Overflow用户

发布于 2018-12-07 19:00:44

如果有人无意中发现了这个问题,现在壳集成还有另一个选择。使用它,您可以使用iTerm定义的变量session.path访问iTerm中的路径。

代码语言:javascript
复制
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
票数 3
EN

Stack Overflow用户

发布于 2014-07-31 18:40:43

这些信息目前无法通过iTerm的AppleScript接口获得。会话对象唯一公开的属性与在其中运行的内容(与其可视化外观相反)是contentstty,而这些属性不是您在这里要寻找的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25051288

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档