Slow terminal open
On MacOS and with iTerm it takes ~1s to open terminal with gtfo, versus opening a new terminal manually with iTerm is instant. Opening Finder does not have this problem and is instant with gtfo. Not sure why, vim profiling does not show anything being slow.
Turns out the reason is that open -a iTerm is much slower than Shell->New Tab (CMD-T) in iTerm.
I don't use iTerm. Open to concrete ideas about how to fix it.
An AppleScript wrapped in a bash function seems to do the trick. Something along:
open_iterm() {
osascript &>/dev/null <<EOF
if application "iTerm" is running then
set isRunning to true
else
set isRunning to false
end if
tell application "iTerm"
if isRunning then
set newWindow to (create window with default profile)
else
try
# iTerm opens a window when launched. Re-use that window.
set newWindow to current window
on error
# iTerm is configured to start without any open windows?
set newWindow to (create window with default profile)
end try
end if
tell newWindow to set sesh to current session
tell sesh to write text "cd $1"
end tell
activate application "iTerm"
EOF
}
A bit verbose, I did not find a better way to avoid opening two windows when iTerm is launched fresh.
It saves ~500ms on my system, when iTerm is already open.
Funny, that's how it used to work, but there was some breaking change between macOS and/or iTerm versions, and it seemed at the time like there was no longer any need for applscript: https://github.com/justinmk/vim-gtfo/pull/26
Not opposed to restoring it in some fashion, since there is a legitimate need.