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

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

  •  
  •   sdjl · Aug 7, 2016 · 4557 views
    This topic created in 3744 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
    flyfire
    Aug 7, 2016 via Android
    1
    apple script
    sdjl
    sdjl
    OP
    Aug 7, 2016
    2
    @flyfire 谢谢,我去看看
    taued
    taued
    Aug 7, 2016❤️1
    3
    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
    ynyounuo
    Aug 7, 2016❤️1
    4
    看你题目的描述以为是需要这个答案:

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

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