2015-02-17 15:20:50 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2015-02-17 16:13:21 +00:00
|
|
|
# for "true full screen" call the script with "fullscreen" as the first argument
|
2015-02-17 15:20:50 +00:00
|
|
|
TRUE_FULL_SCREEN="$1"
|
|
|
|
|
|
|
|
start_iterm_and_run_tmux() {
|
|
|
|
osascript <<-EOF
|
|
|
|
tell application "iTerm"
|
|
|
|
activate
|
|
|
|
|
|
|
|
# open iterm window
|
|
|
|
try
|
2022-07-19 08:28:40 +00:00
|
|
|
set _session to current session of current window
|
2015-02-17 15:20:50 +00:00
|
|
|
on error
|
|
|
|
set _term to (make new terminal)
|
|
|
|
tell _term
|
|
|
|
launch session "Tmux"
|
|
|
|
set _session to current session
|
|
|
|
end tell
|
|
|
|
end try
|
|
|
|
|
|
|
|
# start tmux
|
|
|
|
tell _session
|
|
|
|
write text "tmux"
|
|
|
|
end tell
|
|
|
|
end tell
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
resize_window_to_full_screen() {
|
|
|
|
osascript <<-EOF
|
|
|
|
tell application "iTerm"
|
|
|
|
set winID to id of window 1
|
2022-07-19 08:28:40 +00:00
|
|
|
tell application "Finder"
|
2015-02-17 15:20:50 +00:00
|
|
|
set desktopSize to bounds of window of desktop
|
|
|
|
end tell
|
|
|
|
set bounds of window id winID to desktopSize
|
|
|
|
end tell
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
resize_to_true_full_screen() {
|
|
|
|
osascript <<-EOF
|
|
|
|
tell application "iTerm"
|
2015-02-19 12:43:41 +00:00
|
|
|
# wait for iTerm to start
|
2015-02-17 15:20:50 +00:00
|
|
|
delay 1
|
2015-02-19 12:43:41 +00:00
|
|
|
activate
|
|
|
|
# short wait for iTerm to gain focus
|
|
|
|
delay 0.1
|
|
|
|
# Command + Enter for fullscreen
|
2022-07-19 08:28:40 +00:00
|
|
|
tell application "System Events"
|
2015-02-17 15:20:50 +00:00
|
|
|
key code 36 using {command down}
|
|
|
|
end tell
|
|
|
|
end tell
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
start_iterm_and_run_tmux
|
2015-02-17 16:13:21 +00:00
|
|
|
if [ "$TRUE_FULL_SCREEN" == "fullscreen" ]; then
|
2015-02-17 15:20:50 +00:00
|
|
|
resize_to_true_full_screen
|
|
|
|
else
|
|
|
|
resize_window_to_full_screen
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
main
|