5

If I press Ctrl-B + s, tmux gives me a nice overview of open sessions:

enter image description here

What commands are available from this screen besides Enter, which allows me to switch to the selected session? E.g. can I terminate or rename a session directly from this screen?

1 Answer 1

11

The default binding for prefixs is:

bind-key -T prefix s choose-tree -s

So it's indeed about choose-tree. This is what the manual says:

choose-tree [-GNrswZ] [-F format] [-f filter] [-O sort-order] [-t target-pane] [template]

Put a pane into tree mode, where a session, window or pane may be chosen interactively from a list. -s starts with sessions collapsed and -w with windows collapsed. -Z zooms the pane. The following keys may be used in tree mode:

Key    Function
Enter  Choose selected item
Up     Select previous item
Down   Select next item
x      Kill selected item
X      Kill tagged items
<      Scroll list of previews left
>      Scroll list of previews right
C-s    Search by name
n      Repeat last search
t      Toggle if item is tagged
T      Tag no items
C-t    Tag all items
:      Run a command for each tagged item
f      Enter a format to filter items
O      Change sort field
r      Reverse sort order
v      Toggle preview
q      Exit mode

After a session, window or pane is chosen, %% is replaced by the target in template and the result executed as a command. If template is not given, switch-client -t '%%' is used.

-O specifies the initial sort field: one of index, name, or time. -r reverses the sort order. -f specifies an initial filter: the filter is a format - if it evaluates to zero, the item in the list is not shown, otherwise it is shown. If a filter would lead to an empty list, it is ignored. -F specifies the format for each item in the tree. -N starts without the preview. -G includes all sessions in any session groups in the tree rather than only the first. This command works only if at least one client is attached.

Not all keys work in older versions of tmux though. Refer to man 1 tmux in your OS.


can I terminate or rename a session directly from this screen?

  • Terminate – yes, with x or X.

  • Semi-directly, with : and the desired command, e.g.:

    • :rename-session -t '%%' fooEnter
    • :kill-session -t '%%'Enter
  • Or you can invoke/bind your own variant of choose-tree that will kill session(s) with Enter thanks to a "killing" template you provide:

    choose-tree -s "kill-session -t '%%'"
    

Note you can run a command for multiple items; you just need to tag them with t first. This can be useful with kill-session, maybe less useful with rename-session.

3
  • 1
    Looks like X is available in the latest version of tmux: man7.org/linux/man-pages/man1/tmux.1.html. So it would depend on your version. Oct 29, 2019 at 0:20
  • @JonathanReez True. My answer has been updated. Oct 29, 2019 at 0:39
  • 2
    You shouldn't need to use "-t %%" when using : in tree mode because the default target will be the currently selected pane, window or session. Oct 29, 2019 at 8:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .