前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >在sublime中打开iterm 转

在sublime中打开iterm 转

作者头像
henrylee2cn
发布2019-04-04 15:14:25
1.4K0
发布2019-04-04 15:14:25
举报
文章被收录于专栏:Go实战Go实战

1.安装插件terminal

2.菜单Sublime text -> Preferences -> Browse Packages

3.找到terminal -> Terminal.sh

4.替换粘贴

代码语言:javascript
复制
#!/bin/bash
# Modified following this issue: https://github.com/wbond/sublime_terminal/issues/89
CD_CMD="cd "\\\"$(pwd)\\\"" && clear"
if echo "$SHELL" | grep -E "/fish$" &> /dev/null; then
  CD_CMD="cd "\\\"$(pwd)\\\""; and clear"
fi
VERSION=$(sw_vers -productVersion)
OPEN_IN_TAB=0
while [ "$1" != "" ]; do
    PARAM="$1"
    VALUE="$2"
    case "$PARAM" in
        --open-in-tab)
            OPEN_IN_TAB=1
            ;;
    esac
    shift
done
if (( $(expr $VERSION '<' 10.7) )); then
    RUNNING=$(osascript<<END
    tell application "System Events"
        count(processes whose name is "iTerm")
    end tell
END
)
else
    RUNNING=1
fi
if (( ! $RUNNING )); then
    osascript<<END
    tell application "iTerm"
            tell current window
                tell current session of (create tab with default profile)
                    write text "$CD_CMD"
                end tell
            end tell
            activate
    end tell
END
else
    if (( $OPEN_IN_TAB )); then
        osascript &>/dev/null <<EOF
        tell application "iTerm"
                    if (count of windows) = 0 then
                        set theWindow to (create window with default profile)
                        set theSession to current session of theWindow
                    else
                        set theWindow to current window
                        tell current window
                            set theTab to create tab with default profile
                            set theSession to current session of theTab
                        end tell
                    end if
                    tell theSession
                        write text "$CD_CMD"
                    end tell
                    activate
        end tell
EOF
    else
        osascript &>/dev/null <<EOF
        tell application "iTerm"
                    tell (create window with default profile)
                        tell the current session
                            write text "$CD_CMD"
                        end tell
                    end tell
                    activate
        end tell
EOF
    fi
fi

5.Sublime Text -> Preferences -> Package Settings -> Terminal -> Settings-User

代码语言:javascript
复制
{
  "terminal": "Terminal.sh",
  "parameters": ["open_terminal_project_folder"]
}

注:原sublime text 3 iTerm.sh文件代码如下:

代码语言:javascript
复制
#!/bin/bash

CD_CMD="cd "\\\"$(pwd)\\\"" && clear"
if echo "$SHELL" | grep -E "/fish$" &> /dev/null; then
  CD_CMD="cd "\\\"$(pwd)\\\""; and clear"
fi
VERSION=$(sw_vers -productVersion)
OPEN_IN_TAB=0

while [ "$1" != "" ]; do
    PARAM="$1"
    VALUE="$2"
    case "$PARAM" in
        --open-in-tab)
            OPEN_IN_TAB=1
            ;;
    esac
    shift
done

if (( $(expr $VERSION '<' 10.7) )); then
    RUNNING=$(osascript<<END
    tell application "System Events"
        count(processes whose name is "iTerm")
    end tell
END
)
else
    RUNNING=1
fi

if (( ! $RUNNING )); then
    osascript<<END
    tell application "iTerm"
        tell current terminal
            launch session "Default Session"
            tell the last session
                write text "$CD_CMD"
            end tell
        end tell
    end tell
END
else
    if (( $OPEN_IN_TAB )); then
        osascript &>/dev/null <<EOF
        tell application "iTerm"
            if (count of terminals) = 0 then
                set term to (make new terminal)
            else
                set term to current terminal
            end if
            tell term
                launch session "Default Session"
                tell the last session
                    write text "$CD_CMD"
                end tell
            end tell
        end tell
EOF
    else
        osascript &>/dev/null <<EOF
        tell application "iTerm"
            set term to (make new terminal)
            tell term
                launch session "Default Session"
                tell the last session
                    write text "$CD_CMD"
                end tell
            end tell
        end tell
EOF
    fi
fi

(adsbygoogle = window.adsbygoogle || []).push({});

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017/03/31 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档