mklement0 / ttab

macOS and Linux CLI for opening a new terminal tab/window, optionally with a command to execute and/or display settings
283 stars 15 forks source link

bug? ttab not working when iTerm2 is excluded from Dock #37

Closed emiliohell closed 3 years ago

emiliohell commented 3 years ago

My iTerm2 settings had it excluded from the Dock (Appearance/General/Exclude from Dock and Tab Application Switcher)

This created an issue, that the ttab stopped working correctly, essentially nothing happened when you tried to use a command except for --help.

Removing the setting solves the issue.

mklement0 commented 3 years ago

Thanks for pointing that out, @emiliohell.

The problem is that ttab relies on determining what the frontmost application is and on activating iTerm synchronously.

With the iTerm setting in question, iTerm can no longer be identified as frontmost, and the code that waits for it to become frontmost (to be activated synchronously) hangs (infinite loop).

I'm not aware of a robust workaround - AppleScript simply pretends that iTerm isn't the frontmost application, even when it is.

At limited workaround would be to remove the code that waits for activation to be completed - however, that would still make the -g and -G options malfunction, as they rely on detecting iTerm as the frontmost application.

As a stopgap, you can apply this workaround yourself:

CMD_ACTIVATE='if not frontmost then
  activate
  repeat until frontmost
      delay 0.1
  end repeat
end if'

with:

CMD_ACTIVATE='if not frontmost then
  activate
#  repeat until frontmost
#      delay 0.1
#  end repeat
end if'
mklement0 commented 3 years ago

Should be fixed in v0.7.2, which I've just published to the npm registry; the Homebrew formula has been updated too.

With the hiding-from-doc feature in effect, everything should work again, except for the -g and -G options - if you try to use them while the feature is in effect, an error occurs.