sublime_terminal icon indicating copy to clipboard operation
sublime_terminal copied to clipboard

iTerm2-v3 not launching when not runing

Open davidmasp opened this issue 7 years ago • 13 comments

Hi guys!

Great work here!

When I try to open the iTerm and I have already an iTerm running (other windows open) it works flawlessly. The thing is that if the app is not running it won't launch.

This is my Terminal.sublime-settings.

{
  "terminal": "iTerm2-v3.sh",
  "parameters": ["--open-in-tab"]
}

Other things:

  • when I run the iTerm2-v3.sh directly from iTerm it works.
  • when I run the iTerm2-v3.sh directly from the default terminal it doesn't work.
  • I am running zsh as my default shell
➜  bash iTerm2-v3.sh 
41:47: syntax error: Expected end of line but found class name. (-2741)

davidmasp avatar Jun 17 '17 20:06 davidmasp

Sorry for the slow response. I've been moving this weekend. I'll read this more in depth and think of options by the end of Wednesday

twolfson avatar Jun 19 '17 03:06 twolfson

Alright, so due to your pre-emptive debugging, it seems like an issue in the bash script itself. Can you tell me what happens when you run these lines in /bin/bash when iTerm isn't running?

https://github.com/wbond/sublime_terminal/blob/1.17.0/iTerm2-v3.sh#L21-L43

twolfson avatar Jun 20 '17 06:06 twolfson

Having this problem as well. OS X 10.11.6 iTerm2 3.1.beta.9

sdemura avatar Sep 13 '17 13:09 sdemura

Same problem here.

andremacola avatar Sep 25 '17 18:09 andremacola

looks like iTerm2-v3.sh doesnt have the right permissions on it to be executable

timatron avatar Oct 04 '17 17:10 timatron

I'm not seeing that. On a freshly cloned repo:

ls -la
# -rwxr-xr-x   1 todd todd  1425 Oct  4 21:54 iTerm2-v3.sh

Can someone please tell me what happens when you run https://github.com/wbond/sublime_terminal/issues/171#issuecomment-309662248 ? I'm unable to help otherwise

twolfson avatar Oct 05 '17 04:10 twolfson

@twolfson I just wanted to confirm that on my end when this is installed via package manager, at least, the permissions are not properly set on the iTerm-v3.sh

image

However, changing the permissions to enable execution fixed the issue for me.

I was not able to run the script from the #171 comment you mentioned as it is not complete in itself, but again I don't think the issue is the script itself, I think it's the permissions.

slifty avatar Mar 11 '18 07:03 slifty

@slifty Ah, interesting. Can you submit a PR for that? I'm not sure why it isn't showing up in my git clone =(

twolfson avatar Mar 12 '18 08:03 twolfson

@twolfson It's weird -- I deleted the package files and re-installed (via the Package Control plugin).

The permissions were all set to non-executable, but when I ran it it corrected itself this time.

The permissions in this repo are definitely set correctly; I suspect the issue is related to Package Control somehow. I'm also unable to reproduce it now. I'll try on a fresh machine soon and see if I can figure out the cause.

slifty avatar Mar 12 '18 14:03 slifty

Very strange ._. I took a quick glance through the Package Control issues and can't seem to find anything related. I might later try to create a test repo to reproduce the behavior (hopefully it's not OS specific)

twolfson avatar Mar 12 '18 19:03 twolfson

I don't think I'll have the time to fully set up and test this. I'm going to open an issue on Package Control pointing here =/

twolfson avatar Mar 13 '18 03:03 twolfson

Filed https://github.com/wbond/package_control/issues/1348

twolfson avatar Mar 13 '18 03:03 twolfson

I also encountered the same problem. I do n’t know why I configured it to open with iterm2 according to the README of the sublime_terminal plugin, but it did n’t work for me. Even if I use chmod 755 ./iTerm2-v3.sh to give shell script permissions, it still does n’t work. The final solution is to use: cat ./iTerm2-v3.sh | pbcopy vim Terminal.sh Fill in the contents of the pasteboard into Terminal.sh, use: wq to save and exit, and remove the settings of Terminal in Sublime Text3. Now, the shortcut keys command + shift + t successfully open ITerm2

ClausClaus avatar Apr 16 '20 03:04 ClausClaus

Occasionally the launch of iTerm did not work when it was launched but closed. It seems that iTerm does not delete closed windows that are created via applescript. As a result, (count of windows) is not zero, although there are no windows. Replaced this condition with (exists current window) and now it works.

	if (( $OPEN_IN_TAB )); then
		osascript &>/dev/null <<EOF
		tell application "iTerm"
			if (exists current window) then
				set theWindow to current window
				tell theWindow
					set theTab to create tab with default profile
					set theSession to current session of theTab
				end tell
			else
				set theWindow to (create window with default profile)
				set theSession to current session of theWindow
			end if
			tell theSession
				write text "$CD_CMD"
			end tell
			activate
		end tell
EOF

x100ex avatar Oct 12 '24 09:10 x100ex