Alfred and iTerm2

Alfred and iTerm2

将 Alfred 中的默认 Terminal 更换为 iTerm2

1. 拷贝 Applescript 脚本

Alfred version:

  • 3.1.1
    curl —silent ‘https://raw.githubusercontent.com/stuartcryan/custom-iterm-applescripts-for-alfred/master/custom_iterm_script_iterm_3.1.1.applescript’ | pbcopy
  • 2.9
    curl —silent ‘https://raw.githubusercontent.com/stuartcryan/custom-iterm-applescripts-for-alfred/master/custom_iterm_script_iterm_2.9.applescript’ | pbcopy
  • 2.1.1
    curl —silent ‘https://raw.githubusercontent.com/stuartcryan/custom-iterm-applescripts-for-alfred/master/custom_iterm_script_iterm_2.1.1.applescript’ | pbcopy

或直接下载脚本文件,打开复制,如 Alfred version 3.1.1:

-- This is v0.7 of the custom script for AlfredApp for iTerm 3.1.1+
-- created by Sinan Eldem www.sinaneldem.com.tr

on alfred_script(q)
    if application "iTerm2" is running or application "iTerm" is running then
        run script "
            on run {q}
                tell application \"iTerm\"
                    activate
                    try
                        select first window
                        set onlywindow to true
                    on error
                        create window with default profile
                        select first window
                        set onlywindow to true
                    end try
                    tell the first window
                        if onlywindow is false then
                            create tab with default profile
                        end if
                        tell current session to write text q
                    end tell
                end tell
            end run
        " with parameters {q}
    else
        run script "
            on run {q}
                tell application \"iTerm\"
                    activate
                    try
                        select first window
                    on error
                        create window with default profile
                        select first window
                    end try
                    tell the first window
                        tell current session to write text q
                    end tell
                end tell
            end run
        " with parameters {q}
    end if
end alfred_script

2. 粘贴脚本

打开 Alfred 设置,点击 Features,选择 Terminal / Shell,点击 Application 下拉菜单,选择 Custom,然后将拷贝的脚本内容粘贴进去即可。

3. 脚本仓库

GitHub / LeEnno / Custom iTerm Applescripts for Alfred


文章作者: REPL\ acgio
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 REPL\ acgio !
 上一篇
Hexo 添加 本地搜索 Hexo 添加 本地搜索
使用 hexo-generator-searchdb 插件为 Hexo 添加一个本地站内搜索,效果可见 /search 。 Install 在 Shell 中进入 Hexo 目录,执行 npm install hexo-generator
2019-09-04
下一篇 
Docker 容器重启策略 Docker 容器重启策略
Docker 容器的重启策略 no 默认策略,容器退出时不自动重启容器 on-failure 在容器非 0 退出时自动重启容器 on-failure:10 容器非 0 退出时最多自动重启 10 次 always 在容器退出时总是重启容器
2019-08-22
  目录