Skip to content

Fixed bug with iTerm2 stable/nightly #232

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

Merged
merged 1 commit into from
Jun 1, 2018
Merged

Fixed bug with iTerm2 stable/nightly #232

merged 1 commit into from
Jun 1, 2018

Conversation

philippetev
Copy link
Contributor

The logic of the current scripts for iTerm2 stable/nightly doesn't play well with the iTerm2 startup options (Preferences/General, the Startup dropdown menu). This commit fixes that.

The logic of the current scripts for iTerm2 stable/nightly doesn't play well with the iTerm2 startup options (Preferences/General, the Startup dropdown menu). This commit fixes that.
@thshdw
Copy link
Collaborator

thshdw commented Jun 1, 2018

@philippetev Thanks for taking the time to contribute. Much appreciated.

I have a couple of questions.

  1. What is going on exactly with the current scripts and the Startup dropdown menu?

  2. How extensively have you tested these changes? I have a lot testing in the current syntax using various scenarios. Testing with iTerm closed, testing with iTerm open but all windows closed, testing with multiple iTerm windows etc etc. The syntax here seems to deviate from what is recommended by iTerm https://iterm2.com/documentation-scripting.html

@philippetev
Copy link
Contributor Author

philippetev commented Jun 1, 2018

I noticed weird behavior from iTerm2, when this dropdown menu is used in combination with the Quit when all windows are closed option. Sometimes the app opens no window, sometimes opens several, depending on the states of the above two. The script logic I've implemented works no matter their states. And seeing what was set to execute on new tab (the delay, followed by closing the window) was a surprise for me, IMO this is unnecessary.

I presume getting the windows count and using it to determine if there is an opened one or not is what you call "a deviation". This count operator is part of the Standard suite and it's supported by iTerm2, no matter it's not mentioned in the iTerm2 scripting guide. I suppose you know where to find this dictionary (Script Editor, File, Open Dictionary, iTerm). I've also determined the code that is used more than one time and separated it into subfunctions to be easily called.
Tested all possible scenarios with iTerm2 (opened with/without window, closed), multiple windows (opens the new tab in the last selected/used window) and all possible combinations of the options I've mentioned before. All seems to work like it should.

BTW that scripting guide gave me the idea to merge Legacy, Stable and Nightly in one script for every case that will determine which part of the code it should use automatically, but I've never found some time to work on it.

@thshdw
Copy link
Collaborator

thshdw commented Jun 1, 2018

So the close first window was added because iTerm would start and open a window which was hidden and this was causing two windows to appear when you told shuttle to run a command. The delay was added because in some odd cases shuttle would call iTerm but nothing would happen because iTerm was not ready.

I played around with count but I could never get it working right.

The try catch was added to fix some errors with the close first window see #175

I'll test this out. I've been away for awhile and the applescripts were last tested with iTerm 3.0.10 and I'm sure a lot has changed with iTerm in this period.

@philippetev
Copy link
Contributor Author

So the close first window was added because iTerm would start and open a window which was hidden and this was causing two windows to appear when you told shuttle to run a command. The delay was added because in some odd cases shuttle would call iTerm but nothing would happen because iTerm was not ready.

Noticed that too and the count operator is the ultimate fix for this situation. Hidden or not, the start window changes the windows count value and my logic creates new window only in case count returns 0. That goes for both open in tab and open in window Shuttle settings.

@thshdw
Copy link
Collaborator

thshdw commented Jun 1, 2018

Thanks! I'm going to merge this. I like the structure. Good Job!

@thshdw thshdw merged commit 38a822e into fitztrev:master Jun 1, 2018
@thshdw thshdw mentioned this pull request Jun 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants