• 请不要在回答技术问题时复制粘贴 AI 生成的内容
sdjl
V2EX  ›  程序员

Mac 下有什么命令可以移动焦点到其他 APP?

  •  
  •   sdjl · Aug 7, 2016 · 4229 views
    This topic created in 3590 days ago, the information mentioned may be changed or developed.
    用 Command+tab 可以切换程序焦点对吧,我想实现执行某个命令时切换焦点的某个程序,例如 Chrome

    实现这一步,我就可以在 vim 中通过 F1 实现 保存 -> 用 Chrome 预览 Markdown -> 自动切换到 Chrome
    8 replies    2016-08-08 10:02:16 +08:00
    flyfire
        1
    flyfire  
       Aug 7, 2016 via Android
    apple script
    sdjl
        2
    sdjl  
    OP
       Aug 7, 2016
    @flyfire 谢谢,我去看看
    taued
        3
    taued  
       Aug 7, 2016   ❤️ 1
    open -a /Applications/Google\ Chrome.app [$FILE_PATH]

    -a application
    Specifies the application to use for opening the file

    -n Open a new instance of the application(s) even if one is already running.

    -g Do not bring the application to the foreground.

    其他参数可以 man open 看一下



    if has('gui')
    exec ":silent ! open -g -a \"Google Chrome\"" path
    else
    exec ":! open -g -a \"Google Chrome\"" path
    endif
    ynyounuo
        4
    ynyounuo  
       Aug 7, 2016   ❤️ 1
    看你题目的描述以为是需要这个答案:

    按住 ⌘ 然后可以用鼠标操作别的窗口

    结果进来发现答非所问了。
    那,来都来了。
    kingddc314
        5
    kingddc314  
       Aug 8, 2016 via Android
    3L 说的对,:!open 就行了
    fatestigma
        6
    fatestigma  
       Aug 8, 2016   ❤️ 1
    3L 已经正解,对于 1L 说的 AppleScript ,可以用 `osascript -e 'tell app "Google Chrome" to activate'`。
    sdjl
        7
    sdjl  
    OP
       Aug 8, 2016
    @taued 谢谢,就是这个意思!
    sdjl
        8
    sdjl  
    OP
       Aug 8, 2016
    @fatestigma 谢谢!这个也可以!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2845 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 04:48 · PVG 12:48 · LAX 21:48 · JFK 00:48
    ♥ Do have faith in what you're doing.