tmux integration issues

318 views
Skip to first unread message

David Boyce

unread,
Jun 1, 2016, 8:09:18 PM6/1/16
to iterm2-discuss
I started using the tmux integration a week or so ago and while it has many advantages there are a couple of things that aren't working for me. But maybe I'm just doing something wrong:

-  Sessions and windows seem to time out and I can't find a way to configure this. I'm attaching a screenshot of an empty tmux dashboard; a couple of hours ago this had an active session in the left pane and 6 windows in the right. I went out for dinner, came back, and it's empty. Similarly, even when entire sessions aren't timing out I find that individual windows disappear every so often and must be revived via the dashboard. Is this considered a feature, and is there a way to stop it or extend the timeout?

- I miss the ability to switch windows quickly via the keyboard (vs traditional tmux). Is there by any chance a keyboard navigation matrix I haven't found? It wouldn't have to be the same keystrokes as native tmux, I could learn new strokes, but hunting for the dashboard each time I want a different window is getting old.

- In particular, is there a way to name a window without using the dashboard? Currently when creating a new tmux window I have to go find the dashboard and click the +, then find the dashboard again (because the new window has occluded it) and double click on the new window to name it. This is particularly problematic if a few unnamed windows already exist, because the new window and the previously unnamed ones all look alike (default name of "bash" or whatever) so it's necessary to do a linear search for the new one to be renamed.

Thanks,
David
empty tmux dashboard.png

George Nachman

unread,
Jun 1, 2016, 8:19:08 PM6/1/16
to iterm2-...@googlegroups.com
Issue 1: Timeouts

Weird about your dashboard being empty, assuming you're still connected to a session. Is it possible your ssh session died and the session ended? What do you see in the window where you ran tmux -CC?

Issue 2: Navigation

Hunting around the dashboard is certainly not efficient and I wouldn't wish that on you. The two best options for navigating among windows are:
1. You can use cmd-opt-number to go right to a window (or cmd-number to go to a tab, but you probably knew that). The number you press is the one in the window's title.
2. You can use the Open Quickly feature to search for a subsequence of a tab's title (or various other things, but most of them are related to shell integration, which isn't compatible with tmux integration)

If you want to switch tabs, you can use cmd-shift-[ and cmd-shift-]. Control-Tab cycles through tabs like cmd-tab (if you've been using iTerm2 for a long time you might not have this key mapping, but you can add it in prefs>keys. The action is Cycle Tabs Forward).

To navigate among split panes, use cmd-[ and cmd-]. By default in iTerm2 3.0 this uses a left-to-right top-to-bottom "reading" order. If you prefer a most-recently-used order, there's an advanced preference for this (prefs > advanced > Next Pane and Previous Pane commands use reading order, not the time of last use).


Issue 3: Window naming
You can name a window pane using Edit > Edit Session…. Modify the "Session Title" field, and that will rename the window pane. This is new in version 3.0. I just noticed a bug where it doesn't update the display of the title in the tab right away after you change it like this. Oops. I'll fix that in 3.0.1.


--
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Boyce

unread,
Jun 1, 2016, 9:55:39 PM6/1/16
to iterm2-discuss, gnac...@llamas.org
> Is it possible your ssh session died and the session ended?

I'd be surprised if it was ssh dying. For one thing, I've been using iterm2+ssh+tmux for a year or two and the ssh connection is generally stable for days or weeks. It really never dies on its own, only when the network or VPN is interrupted. The only thing that's changed is that I've added -CC to enable the tmux integration. And this happens repeatedly, not just once. Also, note that individual tmux windows seem to go away occasionally - the loss of the entire session from the dashboard probably happens only when the count of windows in the right pane has gone to zero, though I don't have evidence to prove that yet. Last, if I didn't say it before, if I kill iTerm2 and restart it everything is restored. So the tmux session itself has not died, only its apparent connection with iTerm2.

> What do you see in the window where you ran tmux -CC?

There is no such window. I run the following command from iTerm2 Preferences > Profiles > [profile] > General > Command:

ssh -t m...@company.com "tmux -CC attach -t REMOTE -d || tmux -CC new-session -s REMOTE"

Where would errors from this show up?

> The two best options for navigating among windows are...

Thanks. I see that the tmux prefix character is disabled when using the integration, which makes sense if you consider the prefix character a drawback. From https://gitlab.com/gnachman/iterm2/wikis/TmuxIntegration "Some keystroke must be dedicated to tmux to enter its command mode" and "you have to learn tmux commands." are listed as drawbacks, but there are plenty of people who've made their peace with the tmux prefix character and gotten their fingers used to tmux commands. Personally I use Ctrl-L on the theory that I can use the "clear" command to clear the screen and that's worked very well for me. Anyway, what I'm trying to get to is, rather than disabling the prefix char is it possible the tmux integration could handle it and allow things like <prefix>2 to switch to tab #2 and <prefix>n to cycle right?

David

David Boyce

unread,
Jun 2, 2016, 8:00:55 AM6/2/16
to iterm2-discuss, gnac...@llamas.org
> I'd be surprised if it was ssh dying.

But that may in fact be what's happening. When the empty dashboard happened again a "pgrep -l ssh" on the local side showed no running ssh client, and when I kill ssh deliberately the symptom is the same. I'll try to collect more data (hints on where to look much appreciated).

> Last, if I didn't say it before, if I kill iTerm2 and restart it everything is restored. So the tmux session itself has not died, only its apparent connection with iTerm2.

This is, of course, entirely consistent with the above since restarting iTerm2 restarts ssh too.

David

David Boyce

unread,
Jun 2, 2016, 8:09:53 AM6/2/16
to iterm2-discuss, gnac...@llamas.org
Sorry for all the messages ... current theory is that this is just a regular ssh timeout. Maybe something about the way I was using tmux before (without the integration) was tickling the server enough to keep the connection alive but that doesn't happen with the integration? Anyway, I've added "-o ServerAliveInterval=60" to the ssh command and will see if that fixes it.

David

George Nachman

unread,
Jun 2, 2016, 7:26:07 PM6/2/16
to iterm2-...@googlegroups.com
On Wed, Jun 1, 2016 at 6:55 PM, David Boyce <david....@gmail.com> wrote:
> Is it possible your ssh session died and the session ended?

I'd be surprised if it was ssh dying. For one thing, I've been using iterm2+ssh+tmux for a year or two and the ssh connection is generally stable for days or weeks. It really never dies on its own, only when the network or VPN is interrupted. The only thing that's changed is that I've added -CC to enable the tmux integration. And this happens repeatedly, not just once. Also, note that individual tmux windows seem to go away occasionally - the loss of the entire session from the dashboard probably happens only when the count of windows in the right pane has gone to zero, though I don't have evidence to prove that yet. Last, if I didn't say it before, if I kill iTerm2 and restart it everything is restored. So the tmux session itself has not died, only its apparent connection with iTerm2.

> What do you see in the window where you ran tmux -CC?

There is no such window. I run the following command from iTerm2 Preferences > Profiles > [profile] > General > Command:

ssh -t m...@company.com "tmux -CC attach -t REMOTE -d || tmux -CC new-session -s REMOTE"


Side note: this particular pattern happens not to work very well with tmux integration (two -CC's is confusing to iTerm2). Consider using this instead:

ssh -t m...@company.com  "tmux detach -s REMOTE ; tmux -CC new-session -A -s REMOTE"

Regardless, when you run tmux -CC attach or tmux -CC new-session, there will be a session that shows text like this:

** tmux mode started **

Command Menu
----------------------------
esc    Detach cleanly.
  X    Force-quit tmux mode.
  L    Toggle logging.
  C    Run tmux command.

So my question is what you see there when the windows disappear?

 
> The two best options for navigating among windows are...

Thanks. I see that the tmux prefix character is disabled when using the integration, which makes sense if you consider the prefix character a drawback. From https://gitlab.com/gnachman/iterm2/wikis/TmuxIntegration "Some keystroke must be dedicated to tmux to enter its command mode" and "you have to learn tmux commands." are listed as drawbacks, but there are plenty of people who've made their peace with the tmux prefix character and gotten their fingers used to tmux commands. Personally I use Ctrl-L on the theory that I can use the "clear" command to clear the screen and that's worked very well for me. Anyway, what I'm trying to get to is, rather than disabling the prefix char is it possible the tmux integration could handle it and allow things like <prefix>2 to switch to tab #2 and <prefix>n to cycle right?


One day I plan to add prefix characters to iTerm2 in general, and then this will be a solved problem. Open Quickly is a step in that direction. But offering a separate interface to tmux that has the same keystrokes is a non-goal of tmux integration. The purpose is to provide a seamless experience. To the extent that people find tmux's particular navigation UX desirable, I'd like to make it generally available in iTerm2, but there hasn't been much demand for that except for folks who are coming to tmux integration from plain-ol-tmux so it hasn't been prioritized very high (compared to other things like support for ligatures, hotkey window improvements, etc.).

David Boyce

unread,
Jun 2, 2016, 9:27:43 PM6/2/16
to iterm2-discuss, gnac...@llamas.org
On Thursday, June 2, 2016 at 4:26:07 PM UTC-7, George Nachman wrote:

Side note: this particular pattern happens not to work very well with tmux integration (two -CC's is confusing to iTerm2). Consider using this instead:

ssh -t m...@company.com  "tmux detach -s REMOTE ; tmux -CC new-session -A -s REMOTE"

OK, I will experiment with this form. 

Regardless, when you run tmux -CC attach or tmux -CC new-session, there will be a session that shows text like this:

** tmux mode started **

Command Menu
----------------------------
esc    Detach cleanly.
  X    Force-quit tmux mode.
  L    Toggle logging.
  C    Run tmux command.

So my question is what you see there when the windows disappear?

After adding ServerAliveInterval=60 to the ssh command I haven't seen the windows disappear yet, so will assume that was the solution (interesting that it doesn't seem to have happened to anyone else). But to answer your question anyway, yes I see a window/tab with that text and it goes (went) away with all the other windows leaving only the empty dashboard.
 
One day I plan to add prefix characters to iTerm2 in general, and then this will be a solved problem. Open Quickly is a step in that direction. But offering a separate interface to tmux that has the same keystrokes is a non-goal of tmux integration. The purpose is to provide a seamless experience. To the extent that people find tmux's particular navigation UX desirable, I'd like to make it generally available in iTerm2, but there hasn't been much demand for that except for folks who are coming to tmux integration from plain-ol-tmux so it hasn't been prioritized very high (compared to other things like support for ligatures, hotkey window improvements, etc.).

That's reasonable. The fact is, after a few days of getting used to it most of the pain points I was experiencing have dissipated. For instance double-clicking on a tab allows it to be renamed, which is easier than Edit > Session etc. Being able to reorder and group tabs with drag and drop is a real boon, and the fact that they automatically renumber is very nice

One thing I still miss from plain-old-tmux is the ability to use <prefix><prefix> to swap to the most recently used window. I used this heavily to swap between edit and debug windows in the same project. There doesn't seem to be a native Mac shortcut for this, which is unfortunate, but otherwise I'm getting increasingly comfortable with the integration.

A couple of minor suggestions:

- When the tmux integration is configured to "open tmux windows as tabs in existing window", the dashboard still says "Open in Window" at bottom right. Wouldn't it be better to say "Open in Tab" in that case?
- Say a session has 8 tmux windows. In a new connection none of them are instantiated as iTerm2 windows/tabs and it's necessary to use the dashboard to do so. Previously I was laboriously clicking through each one and using Open in Window to instantiate it 8 times. Now I realize the full set can be selected with cmd-a and instantiated with one click, which is way better, but still: is there a configurable like "instantiate all tmux windows at connect time"?

George Nachman

unread,
Jun 3, 2016, 6:28:02 PM6/3/16
to iterm2-...@googlegroups.com
On Thu, Jun 2, 2016 at 6:27 PM, David Boyce <david....@gmail.com> wrote:
On Thursday, June 2, 2016 at 4:26:07 PM UTC-7, George Nachman wrote:

Side note: this particular pattern happens not to work very well with tmux integration (two -CC's is confusing to iTerm2). Consider using this instead:

ssh -t m...@company.com  "tmux detach -s REMOTE ; tmux -CC new-session -A -s REMOTE"

OK, I will experiment with this form. 

Regardless, when you run tmux -CC attach or tmux -CC new-session, there will be a session that shows text like this:

** tmux mode started **

Command Menu
----------------------------
esc    Detach cleanly.
  X    Force-quit tmux mode.
  L    Toggle logging.
  C    Run tmux command.

So my question is what you see there when the windows disappear?

After adding ServerAliveInterval=60 to the ssh command I haven't seen the windows disappear yet, so will assume that was the solution (interesting that it doesn't seem to have happened to anyone else). But to answer your question anyway, yes I see a window/tab with that text and it goes (went) away with all the other windows leaving only the empty dashboard.
 

Sounds like the ssh session died or the shell terminated for some other reason. I guess you have "Prefs>Profiles>Session>Automatically close a session when it ends" turned on, which is why the tmux gateway (the session where you ran tmux -CC) went away without you being able to see what happened.
 
One day I plan to add prefix characters to iTerm2 in general, and then this will be a solved problem. Open Quickly is a step in that direction. But offering a separate interface to tmux that has the same keystrokes is a non-goal of tmux integration. The purpose is to provide a seamless experience. To the extent that people find tmux's particular navigation UX desirable, I'd like to make it generally available in iTerm2, but there hasn't been much demand for that except for folks who are coming to tmux integration from plain-ol-tmux so it hasn't been prioritized very high (compared to other things like support for ligatures, hotkey window improvements, etc.).

That's reasonable. The fact is, after a few days of getting used to it most of the pain points I was experiencing have dissipated. For instance double-clicking on a tab allows it to be renamed, which is easier than Edit > Session etc. Being able to reorder and group tabs with drag and drop is a real boon, and the fact that they automatically renumber is very nice

One thing I still miss from plain-old-tmux is the ability to use <prefix><prefix> to swap to the most recently used window. I used this heavily to swap between edit and debug windows in the same project. There doesn't seem to be a native Mac shortcut for this, which is unfortunate, but otherwise I'm getting increasingly comfortable with the integration.


In iTerm2, control-tab will swap between your current tab and your most-recently-used tab in the same window. If you want to switch between windows cmd-backtick (`) will do it, as you probably know.
 
A couple of minor suggestions:

- When the tmux integration is configured to "open tmux windows as tabs in existing window", the dashboard still says "Open in Window" at bottom right. Wouldn't it be better to say "Open in Tab" in that case?

Getting the UI right on this will be tricky, but I opened an issue to track it: https://gitlab.com/gnachman/iterm2/issues/4732
 
- Say a session has 8 tmux windows. In a new connection none of them are instantiated as iTerm2 windows/tabs and it's necessary to use the dashboard to do so. Previously I was laboriously clicking through each one and using Open in Window to instantiate it 8 times. Now I realize the full set can be selected with cmd-a and instantiated with one click, which is way better, but still: is there a configurable like "instantiate all tmux windows at connect time"?

If you have a lot of windows then the dashboard opens instead of the windows. See prefs>general>open dashboard if there are more than X tmux windows. You can increase X if this is what you're doing all the time. It gets slow if you open a huge number of windows at connection time. Maybe the default limit of 10 is too low?

David Boyce

unread,
Jun 4, 2016, 9:32:23 PM6/4/16
to iterm2-discuss, gnac...@llamas.org
On Friday, June 3, 2016 at 3:28:02 PM UTC-7, George Nachman wrote:
I guess you have "Prefs>Profiles>Session>Automatically close a session when it ends" turned on, which is why the tmux gateway (the session where you ran tmux -CC) went away without you being able to see what happened.

Ah, I see now, but this issue is resolved anyway.
 
In iTerm2, control-tab will swap between your current tab and your most-recently-used tab in the same window.

Control-tab is exactly what I was looking for, thanks.

If you have a lot of windows then the dashboard opens instead of the windows. See prefs>general>open dashboard if there are more than X tmux windows. You can increase X if this is what you're doing all the time. It gets slow if you open a huge number of windows at connection time. Maybe the default limit of 10 is too low?

No, I don't think the problem is with the default. Now that I understand it better, I think the only problem is with the textual description. It says "open dashboard if there are more than 10 windows" but from what you're saying I think this really means "rely on dashboard instead of instantiating windows if there are more than 10 windows. Because from what I can see the dashboard opens in all cases (whether the configured value is larger or smaller than the current number of windows); the difference between the two cases is just whether the windows listed in the dashboard are also instantiated as actual windows/tabs. Not understanding this, I'd set the value extra low (1) to force the dashboard to be started without realizing I was shooting myself in the foot since it prevented the windows from being started automatically. I think if the situation was clearly explained people would have no trouble configuring the setting they like.

David

David Boyce

unread,
Jun 5, 2016, 10:53:20 AM6/5/16
to iterm2-discuss, gnac...@llamas.org
In summary, almost everything I thought was a problem turns out to have a good answer, which is great and no complaints from here. But let me elaborate on the dashboard situation a little because there's either a bug or yet another misunderstanding wrt the "Open dashboard if there are more than X windows" preference. Say there are 8 tmux windows and X=20; when I start iTerm2 from scratch and it initiates the ssh/tmux connection, all 8 windows are automatically instantiated (as tabs in my case due to the other setting). But the dashboard is still opened which makes no sense to me. For one thing, it's not needed since all windows are already present and for another it's in direct contravention of "Open dashboard if there are more than 20 windows" since there are only 8. It's easily closed, of course, but still its presence doesn't seem correct in this circumstance.

George Nachman

unread,
Jun 5, 2016, 9:14:53 PM6/5/16
to David Boyce, iterm2-discuss
The dashboard opens if you have at least one hidden window. If all the windows have been opened then the dashboard will not open. Find the windows in the dashboard whose names are grayed out, select them, and click open in windows/tabs. Next time you attach the dashboard should nt open.
Reply all
Reply to author
Forward
0 new messages