+4

"Open Terminal here" as tab instead of window if possible

Brian Gilbert 13 jaar geleden bijgewerkt 13 jaar geleden 0
I used the iTerm.sh as a basis for this:

#!/bin/bash

CD_CMD="cd "\\\"$(pwd)\\\"" && clear"
VERSION=$(sw_vers -productVersion)

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

if (( $RUNNING )); then
    osascript<<END
  tell application "System Events"
    tell process "Terminal" to keystroke "t" using command down
  end
    tell application "Terminal"
        activate
        do script with command "$CD_CMD" in window 1
    end tell
END
else
    osascript<<END
    tell application "Terminal"
        activate
        do script with command "$CD_CMD" in window 1
        end tell
    end tell
END
fi