Add support for launching iTerm 2.9+

The AppleScript bridge changed at some point since 2.1. While marked as
beta, the 2.9 series is the author's recommended version to use.

The two bridges are incompatible, requiring another function and version
checks.
This commit is contained in:
Jonathan Cremin 2015-07-23 13:10:40 +01:00
parent bdf9b95906
commit ff6d9323fd
1 changed files with 44 additions and 17 deletions

View File

@ -16,7 +16,16 @@ EOF`
function open_iterm () {
osascript > /dev/null <<EOF
tell application "iTerm"
if version < 2.9 then
activate
try
tell current window
create tab with default profile
tell the current session of current window
write text "bash -c \"$CMD\""
end tell
end tell
on error
try
tell the first terminal
launch session "Default Session"
@ -32,6 +41,24 @@ function open_iterm () {
end tell
end tell
end try
end try
end if
end tell
EOF
}
function open_iterm2point9 () {
osascript > /dev/null <<EOF
tell application "iTerm"
if version ≥ 2.9 then
activate
tell current window
create tab with default profile
tell first session of current tab
write text "bash -c \"$CMD\""
end tell
end tell
end if
end tell
EOF
}
@ -48,7 +75,7 @@ EOF
}
if [ "$ITERM_EXISTS" == "true" ]; then
open_iterm "$@" || open_terminal "$@"
open_iterm2point9 "$@" || open_iterm "$@" || open_terminal "$@"
else
open_terminal "$@"
fi