Discussion:
[iterm2-discuss] tmux - detach, kill, hide - suggested tweaks
David Rees
2018-06-22 03:09:22 UTC
Permalink
Note, you said "You can already choose between detach or hide when doing
cmd-w or clicking the red button.", but actually the only options are
kill/cancel/hide. I think the rest of your text implies you know/meant it
is kill/hide.

Thanks for the tip on setting a key. There actually is a key for
tmux/detach (Shift-Ctrl-Cmd-D), but it is kind of hard to remember/press. I
added Cmd-Opt-W so I can quickly use it after I first try Cmd-W and get the
dialog.

Is there a reason detach can't also be one of the dialog options with
option to make it the default? I personally would always like Cmd-W to be
detach when it is a tmux CC window (and have Cmd-W be normal close when it
isn't a tmux window).

API looks really powerful! I didn't see anything for walking the tmux
sessions and windows though?

Thanks!
dave
You can already choose between detach or hide when doing cmd-w or clicking
the red button. There's a prompt which shows by default but can be
permanently suppressed. If you'd like it back, turn off Prefs > Advanced >
Suppress kill/hide dialog when closing a tmux tab. There's another
similarly named advanced pref for tmux windows.
It sounds to me like what's missing is a way to easily detach since the
tmux dashboard is kind of a hassle to open.
One thing you can do is bind a keystroke to detach. Go to Prefs > Keys and
add a new key binding. For the action, choose Select Menu Item
 (it's the
last one). Then you can pick a menu item in the lower select list. Scroll
down until you find Detach.
As for scripting, this is coming along nicely in the nightly build. I need
https://iterm2.com/python-api
I am using tmux -CC with "Automatically bury the tmux client session
after connecting".
I connect by running my "connect command" of `ssh servername -t tmux -CC
- ssh's to the server
- closes the current/controlling iterm window
- opens the tmux iterm window for session myname.
I would like to be able to be able to exit the tmux window and then come
back to the tmux session again later by doing the connect command again.
It seems like there are three ways to close the window and all of them
1 - detach - close via window red button
- I click on the tmux iterm window's red close button
- iterm tmux window closes
- I am returned to the controlling iterm window with tmux/ssh exited
- I then need to close that controlling window also.
- The iterm tmux dashboard shows that the tmux session still exists
I can then use the connect command above to reconnect from a different
iterm window and everything works fine.
- I press Cmd-W. I am them asked if I want to "kill or hide".
- I choose "kill".
- Both the tmux iterm window and control iterm window are closed. The
underlying tmux and ssh are closed also I assume.
- The tmux session is killed.
- The iterm tmux dashboard no longer shows the tmux session.
When I do the connect command I get a new session. So my session has been
lost (as expected with a term like kill).
- I do Cmd-W and choose hide.
- The iterm tmux window is hidden and the iterm control window
remains hidden also.
- The iterm tmux dashboard shows the session and its window.
When I do the connect command again in a 2nd iterm window I get a dialog
box that says "This instance of iterm2 is already attached to this
session.". When I click OK I see in the 2nd iterm control window that the
tmux command has ended and therefore the ssh session has ended.
I would like to suggest a couple tweaks.
That when Cmd-W is pressed, there should be a "detach" option also that
works the same as #1 (pressing the red button).
That the close button works the same as Cmd-W. So a user would have a
choice of detach, kill, or hide.
That when a existing session myname is hidden and the user tries to
attach to it (tmux -CC a -t myname). That the session is unhidden. The 2nd
controlling iterm tmux window can still exit tmux, but it does so with a
warning message to make it clear what happened.
Provide command line or applescript API for interacting with the iterm
tmux Dashboard. This will allow users to script checking what sessions
exist. I personally would like to see iterm tmux session management added
to Quicksilver for example :). I know this last one is non-trivial :).
Thanks!
dave
--
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
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the
Google Groups "iterm2-discuss" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/iterm2-discuss/rrcj-wtsAEc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
For more options, visit https://groups.google.com/d/optout.
--
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-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
George Nachman
2018-06-23 16:54:00 UTC
Permalink
Oh, you mean to detach from the tmux session altogether? That's a good
idea. I haven't exposed any tmux stuff in the API yet, but I will.
Post by David Rees
Note, you said "You can already choose between detach or hide when doing
cmd-w or clicking the red button.", but actually the only options are
kill/cancel/hide. I think the rest of your text implies you know/meant it
is kill/hide.
Thanks for the tip on setting a key. There actually is a key for
tmux/detach (Shift-Ctrl-Cmd-D), but it is kind of hard to remember/press. I
added Cmd-Opt-W so I can quickly use it after I first try Cmd-W and get the
dialog.
Is there a reason detach can't also be one of the dialog options with
option to make it the default? I personally would always like Cmd-W to be
detach when it is a tmux CC window (and have Cmd-W be normal close when it
isn't a tmux window).
API looks really powerful! I didn't see anything for walking the tmux
sessions and windows though?
Thanks!
dave
You can already choose between detach or hide when doing cmd-w or
clicking the red button. There's a prompt which shows by default but can be
permanently suppressed. If you'd like it back, turn off Prefs > Advanced >
Suppress kill/hide dialog when closing a tmux tab. There's another
similarly named advanced pref for tmux windows.
It sounds to me like what's missing is a way to easily detach since the
tmux dashboard is kind of a hassle to open.
One thing you can do is bind a keystroke to detach. Go to Prefs > Keys
and add a new key binding. For the action, choose Select Menu Item
 (it's
the last one). Then you can pick a menu item in the lower select list.
Scroll down until you find Detach.
As for scripting, this is coming along nicely in the nightly build. I
https://iterm2.com/python-api
I am using tmux -CC with "Automatically bury the tmux client session
after connecting".
I connect by running my "connect command" of `ssh servername -t tmux -CC
- ssh's to the server
- closes the current/controlling iterm window
- opens the tmux iterm window for session myname.
I would like to be able to be able to exit the tmux window and then come
back to the tmux session again later by doing the connect command again.
It seems like there are three ways to close the window and all of them
1 - detach - close via window red button
- I click on the tmux iterm window's red close button
- iterm tmux window closes
- I am returned to the controlling iterm window with tmux/ssh exited
- I then need to close that controlling window also.
- The iterm tmux dashboard shows that the tmux session still exists
I can then use the connect command above to reconnect from a different
iterm window and everything works fine.
- I press Cmd-W. I am them asked if I want to "kill or hide".
- I choose "kill".
- Both the tmux iterm window and control iterm window are closed.
The underlying tmux and ssh are closed also I assume.
- The tmux session is killed.
- The iterm tmux dashboard no longer shows the tmux session.
When I do the connect command I get a new session. So my session has
been lost (as expected with a term like kill).
- I do Cmd-W and choose hide.
- The iterm tmux window is hidden and the iterm control window
remains hidden also.
- The iterm tmux dashboard shows the session and its window.
When I do the connect command again in a 2nd iterm window I get a dialog
box that says "This instance of iterm2 is already attached to this
session.". When I click OK I see in the 2nd iterm control window that the
tmux command has ended and therefore the ssh session has ended.
I would like to suggest a couple tweaks.
That when Cmd-W is pressed, there should be a "detach" option also that
works the same as #1 (pressing the red button).
That the close button works the same as Cmd-W. So a user would have a
choice of detach, kill, or hide.
That when a existing session myname is hidden and the user tries to
attach to it (tmux -CC a -t myname). That the session is unhidden. The 2nd
controlling iterm tmux window can still exit tmux, but it does so with a
warning message to make it clear what happened.
Provide command line or applescript API for interacting with the iterm
tmux Dashboard. This will allow users to script checking what sessions
exist. I personally would like to see iterm tmux session management added
to Quicksilver for example :). I know this last one is non-trivial :).
Thanks!
dave
--
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
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the
Google Groups "iterm2-discuss" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/iterm2-discuss/rrcj-wtsAEc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
For more options, visit https://groups.google.com/d/optout.
--
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
For more options, visit https://groups.google.com/d/optout.
--
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-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
George Nachman
2018-06-23 23:55:59 UTC
Permalink
If you want to detach from a tmux session, you can actually do that already
by using Shell>Tmux>Detach, which can be invoked from an API using
app.async_select_menu_item("tmux.Detach") when a tmux session from the
connection in question is active.

If you'd like more power, I've added some tmux APIs documented here:
https://iterm2.com/python-api/tmux.html

They'll be available in tomorrow's nightly build.
Post by George Nachman
Oh, you mean to detach from the tmux session altogether? That's a good
idea. I haven't exposed any tmux stuff in the API yet, but I will.
Post by David Rees
Note, you said "You can already choose between detach or hide when doing
cmd-w or clicking the red button.", but actually the only options are
kill/cancel/hide. I think the rest of your text implies you know/meant it
is kill/hide.
Thanks for the tip on setting a key. There actually is a key for
tmux/detach (Shift-Ctrl-Cmd-D), but it is kind of hard to remember/press. I
added Cmd-Opt-W so I can quickly use it after I first try Cmd-W and get the
dialog.
Is there a reason detach can't also be one of the dialog options with
option to make it the default? I personally would always like Cmd-W to be
detach when it is a tmux CC window (and have Cmd-W be normal close when it
isn't a tmux window).
API looks really powerful! I didn't see anything for walking the tmux
sessions and windows though?
Thanks!
dave
You can already choose between detach or hide when doing cmd-w or
clicking the red button. There's a prompt which shows by default but can be
permanently suppressed. If you'd like it back, turn off Prefs > Advanced >
Suppress kill/hide dialog when closing a tmux tab. There's another
similarly named advanced pref for tmux windows.
It sounds to me like what's missing is a way to easily detach since the
tmux dashboard is kind of a hassle to open.
One thing you can do is bind a keystroke to detach. Go to Prefs > Keys
and add a new key binding. For the action, choose Select Menu Item
 (it's
the last one). Then you can pick a menu item in the lower select list.
Scroll down until you find Detach.
As for scripting, this is coming along nicely in the nightly build. I
https://iterm2.com/python-api
I am using tmux -CC with "Automatically bury the tmux client session
after connecting".
I connect by running my "connect command" of `ssh servername -t tmux
- ssh's to the server
- closes the current/controlling iterm window
- opens the tmux iterm window for session myname.
I would like to be able to be able to exit the tmux window and then
come back to the tmux session again later by doing the connect command
again.
It seems like there are three ways to close the window and all of them
1 - detach - close via window red button
- I click on the tmux iterm window's red close button
- iterm tmux window closes
- I am returned to the controlling iterm window with tmux/ssh exited
- I then need to close that controlling window also.
- The iterm tmux dashboard shows that the tmux session still exists
I can then use the connect command above to reconnect from a different
iterm window and everything works fine.
- I press Cmd-W. I am them asked if I want to "kill or hide".
- I choose "kill".
- Both the tmux iterm window and control iterm window are closed.
The underlying tmux and ssh are closed also I assume.
- The tmux session is killed.
- The iterm tmux dashboard no longer shows the tmux session.
When I do the connect command I get a new session. So my session has
been lost (as expected with a term like kill).
- I do Cmd-W and choose hide.
- The iterm tmux window is hidden and the iterm control window
remains hidden also.
- The iterm tmux dashboard shows the session and its window.
When I do the connect command again in a 2nd iterm window I get a
dialog box that says "This instance of iterm2 is already attached to this
session.". When I click OK I see in the 2nd iterm control window that the
tmux command has ended and therefore the ssh session has ended.
I would like to suggest a couple tweaks.
That when Cmd-W is pressed, there should be a "detach" option also that
works the same as #1 (pressing the red button).
That the close button works the same as Cmd-W. So a user would have a
choice of detach, kill, or hide.
That when a existing session myname is hidden and the user tries to
attach to it (tmux -CC a -t myname). That the session is unhidden. The 2nd
controlling iterm tmux window can still exit tmux, but it does so with a
warning message to make it clear what happened.
Provide command line or applescript API for interacting with the iterm
tmux Dashboard. This will allow users to script checking what sessions
exist. I personally would like to see iterm tmux session management added
to Quicksilver for example :). I know this last one is non-trivial :).
Thanks!
dave
--
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
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the
Google Groups "iterm2-discuss" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/iterm2-discuss/rrcj-wtsAEc/unsubscribe
.
To unsubscribe from this group and all its topics, send an email to
For more options, visit https://groups.google.com/d/optout.
--
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
For more options, visit https://groups.google.com/d/optout.
--
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-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...