Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow terminal open #41

Open
ptzz opened this issue Aug 16, 2017 · 4 comments
Open

Slow terminal open #41

ptzz opened this issue Aug 16, 2017 · 4 comments
Labels

Comments

@ptzz
Copy link

ptzz commented Aug 16, 2017

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.

@ptzz
Copy link
Author

ptzz commented Aug 16, 2017

Turns out the reason is that open -a iTerm is much slower than Shell->New Tab (CMD-T) in iTerm.

@justinmk
Copy link
Owner

I don't use iTerm. Open to concrete ideas about how to fix it.

@justinmk justinmk added the bug label Aug 16, 2017
@ptzz
Copy link
Author

ptzz commented Aug 16, 2017

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.

@justinmk
Copy link
Owner

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: #26

Not opposed to restoring it in some fashion, since there is a legitimate need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants