-
-
Save FlyingFish07/3f7df52b92f8c0d1b0b117ee9440f97f to your computer and use it in GitHub Desktop.
sublime_terminal插件启动iTerm2 3.0+终端
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 "iTerm2") | |
| end tell | |
| END | |
| ) | |
| else | |
| RUNNING=1 | |
| fi | |
| if (( ! $RUNNING )); then | |
| osascript<<END | |
| tell application "iTerm" | |
| activate | |
| tell current session of current window | |
| write text "$CD_CMD" | |
| end tell | |
| end tell | |
| END | |
| else | |
| if (( $OPEN_IN_TAB )); then | |
| osascript &>/dev/null <<EOF | |
| tell application "iTerm" | |
| activate | |
| tell current window | |
| select | |
| create tab with default profile | |
| tell current session of current tab | |
| write text "$CD_CMD" | |
| end tell | |
| end tell | |
| end tell | |
| EOF | |
| else | |
| osascript &>/dev/null <<EOF | |
| tell application "iTerm" | |
| create window with default profile | |
| tell current session of current window | |
| write text "$CD_CMD" | |
| end tell | |
| end tell | |
| EOF | |
| fi | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment