mirror of https://github.com/docker/docs.git
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:
parent
bdf9b95906
commit
ff6d9323fd
|
|
@ -16,22 +16,49 @@ EOF`
|
||||||
function open_iterm () {
|
function open_iterm () {
|
||||||
osascript > /dev/null <<EOF
|
osascript > /dev/null <<EOF
|
||||||
tell application "iTerm"
|
tell application "iTerm"
|
||||||
activate
|
if version < 2.9 then
|
||||||
try
|
activate
|
||||||
tell the first terminal
|
try
|
||||||
launch session "Default Session"
|
tell current window
|
||||||
tell the last session
|
create tab with default profile
|
||||||
write text "bash -c \"$CMD\""
|
tell the current session of current window
|
||||||
end tell
|
write text "bash -c \"$CMD\""
|
||||||
end tell
|
end tell
|
||||||
on error
|
end tell
|
||||||
tell (make new terminal)
|
on error
|
||||||
launch session "Default Session"
|
try
|
||||||
tell the last session
|
tell the first terminal
|
||||||
write text "bash -c \"$CMD\""
|
launch session "Default Session"
|
||||||
end tell
|
tell the last session
|
||||||
end tell
|
write text "bash -c \"$CMD\""
|
||||||
end try
|
end tell
|
||||||
|
end tell
|
||||||
|
on error
|
||||||
|
tell (make new terminal)
|
||||||
|
launch session "Default Session"
|
||||||
|
tell the last session
|
||||||
|
write text "bash -c \"$CMD\""
|
||||||
|
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
|
end tell
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
@ -48,7 +75,7 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$ITERM_EXISTS" == "true" ]; then
|
if [ "$ITERM_EXISTS" == "true" ]; then
|
||||||
open_iterm "$@" || open_terminal "$@"
|
open_iterm2point9 "$@" || open_iterm "$@" || open_terminal "$@"
|
||||||
else
|
else
|
||||||
open_terminal "$@"
|
open_terminal "$@"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue