解决Mac Subl下Terminal插件中打开iTerm2

2016-12-26 09:27:59来源:作者:信鑫-King's Blog人点击

Sublime下为了直接在项目中打开iTerm,解决问题会相当高效。而Sublime中的Terminal插件中,官方给的iTerm.sh并不能打开iTerm2。这就很尴尬了!曾经就为了这个原因,转用WebStorm,想达到这样的效果。

具体解决如下:

Sublime中 Preferences -> browse packages 中找到 Terminal 文件夹,然后找到 iTerm.sh 文件。然后就将下列代码粘贴进去。

#!/bin/bashCD_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=0while [ "$1" != "" ]; do PARAM="$1" VALUE="$2" case "$PARAM" in --open-in-tab) OPEN_IN_TAB=1 ;; esac shiftdoneif (( $(expr $VERSION '<' 10.7) )); then RUNNING=$(osascript<<END tell application "System Events" count(processes whose name is "iTerm") end tellEND )else RUNNING=1fiif (( ! $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 tellEND 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 tellEOF 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 tellEOF fifi

然后在用户设置一下: Preferences -> Package Settings -> Terminal -> Settings-User

{ "terminal": "iTerm.sh", "parameters": ["open_terminal_project_folder"]}

就可以用了~~~

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台