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

Update iTerm script #26

Merged
merged 1 commit into from
Nov 30, 2014
Merged

Update iTerm script #26

merged 1 commit into from
Nov 30, 2014

Conversation

kevintraver
Copy link

iTerm2 made some changes to its scripting, which causes 'got' to silently fail when using iTerm2, and setting
let g:gtfo#terminals = { 'mac' : 'iterm' }

Here is the new scripting commands:
https://github.com/gnachman/iTerm2/blob/master/iTerm2.sdef

Perhaps it might be necessary to check and have separate scripts for iTerm/iTerm2.
Thoughts?

@justinmk
Copy link
Owner

Thanks for digging into this. Are you saying it doesn't work for older iTerm2 releases?

With your changes, what's the behavior if you are in, say, MacVim? Does got bring iTerm2 to the foreground (it should)?

@kevintraver
Copy link
Author

Yes the functionality appears to be the same. And yes, this would break old releases.

On a related note, it seems it might be possible to drop applescript all together.

Calling the system command works just fine even with iterm:

silent call system("open -a ".s:termpath." '".l:dir."'")

@justinmk
Copy link
Owner

Dropping applescript would be great.

silent call system("open -a ".s:termpath." '".l:dir."'")

Does that work for the following cases:

  • if iterm isn't running, it starts iterm and focuses the new terminal
  • if iterm is running but not focused (e.g. if user is using MacVim), it focuses iterm and creates a new tab
  • if iterm is running and focused it creates a new tab

@kevintraver
Copy link
Author

Yes, it works for all those cases.

@@ -139,7 +139,7 @@ func! gtfo#open#term(dir, cmd) "{{{
call s:restore_shell()
elseif s:ismac
if (s:empty(s:termpath) && $TERM_PROGRAM ==? 'iTerm.app') || s:termpath ==? "iterm"
silent call s:mac_open_iTerm(l:dir)
silent call system("open -a ".s:termpath." '".l:dir."'")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a line above this for the empty case, similar to line 144:

if s:empty(s:termpath) | let s:termpath = 'iTerm.app' | endif

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, that will break on the next invocation (because s:termpath is no longer empty). Instead, it can just be:

     if (s:empty(s:termpath) && $TERM_PROGRAM ==? 'iTerm.app') || s:termpath ==? "iterm"
       silent call system("open -a iTerm '".l:dir."'")

@justinmk
Copy link
Owner

@kevintraver Thanks. Can you squash to 1 commit?

justinmk added a commit that referenced this pull request Nov 30, 2014
@justinmk justinmk merged commit b663ccc into justinmk:master Nov 30, 2014
@justinmk
Copy link
Owner

Thanks!

@kevintraver kevintraver deleted the fix_iterm2_applescript branch December 1, 2014 05:47
@justinmk justinmk mentioned this pull request Aug 16, 2017
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