tmux history and bookmarks

30 views
Skip to first unread message

Roberto

unread,
Sep 3, 2020, 4:37:44 AM9/3/20
to tmux-...@googlegroups.com
I have maybe 100 panes in 10+ sessions kept running thanks to tmux. These are mostly to collect a separate bash history for different repetitive, but not completely predictable, tasks.

Navigating this many sessions and panes is a bit of a pain, but I think there are possible helping features in tmux.

I could exploit a "history" and a "bookmarks" panel, pretty much similar to those you have in web browsers. Is there anything like that in tmux as of now?

Nicholas Marriott

unread,
Sep 3, 2020, 4:51:16 AM9/3/20
to Roberto, tmux-users
If you go into tree mode and press O to change the sort order, one of the orders is by time which will show sessions and windows in order of activity time.

tmux does maintain a stack of the last windows for each session and there is no reason it couldn't sort each session's windows using it but currently it is not possible.

There is no way to set bookmarks but it doesn't seem terribly useful to me - that's what window and session names are for.


--
You received this message because you are subscribed to the Google Groups "tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tmux-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/tmux-users/22B4DC91-0C1D-4BE0-A8C6-FE5B1577C9EC%40gmail.com.

Clint Hepner

unread,
Sep 3, 2020, 7:57:36 AM9/3/20
to Roberto, tmux-...@googlegroups.com

> On Sep 3, 2020, at 4:37 AM, Roberto <foice...@gmail.com> wrote:
>
> I have maybe 100 panes in 10+ sessions kept running thanks to tmux. These are mostly to collect a separate bash history for different repetitive, but not completely predictable, tasks.

To me, that says you have something you could capture in one or more parameterized scripts or functions, rather than constantly editing a command from history.

--
Clint

Roberto Franceschini

unread,
Sep 3, 2020, 8:19:11 AM9/3/20
to tmux-users
Thanks a lot for pointing the capital O key for changing the sort ordering. It does exactly what I was looking for and it seems to sort both sessions and windows inside each session. This is very nice. 
I was wondering if I can make this my default sorting, instead of pressing O twice every time I open the sessions or windows lists.

Also, what part of the documentation would be relevant to read more on this and other ways to interact with the windows lists?

Concerning bookmarks, you are correct, the windows name is the place to use. I have chosen to have windows names set dynamically from the path of the folder they are in, so I have given up that in favor of showing PWD in the window name. The bookmarks where more intended to have a subset of the existing windows reachable pressing a single key, a sort of quick-dial in which you list only a subset of the windows you have and can access them by a conifgurable single stroke (e.g. b for build, r for run, d for debug and so no ...). Maybe I am just thinking about a configurable shortcut for certain windows, indest of having them bound to the standard 0-10 M-a to M-z. Can these be configured to access a given window of a given session by one single user-defined key or sequence?

Best
Roberto

Nicholas Marriott

unread,
Sep 3, 2020, 8:28:56 AM9/3/20
to Roberto Franceschini, tmux-users
You can change the s and w key bindings to add -Otime, something like:

bind s choose-tree -Zs -Otime
bind w choose-tree -Zw -Otime

You can look at these for choose-tree:


You can use filters to show only a subset, for example:

choose-tree -Zw -f '#{m:*sh,#{window_name}}'

Of course the filter can be much more complicated than this.

If you want to create subsets of windows you could set a user option, for example do this on the windows you want:

set -w @mysubset 'yes'

And then you can filter only the ones where this option is set:

choose-tree -Zw -f '#{==:yes,#{@mysubset}}'

Of course you can bind these to keys to make them easier to use.

find-window (C-b f) works by generating filters automatically for tree mode.

See:




Nicholas Marriott

unread,
Sep 3, 2020, 8:30:51 AM9/3/20
to Roberto Franceschini, tmux-users
Another thing you could do if you are using 3.2-rc or master is to write a simple shell script that shows a menu to choose a window or session in a way you want, or uses something like dialog or fzf, and open it in a popup using display-popup.

Nicholas Marriott

unread,
Sep 3, 2020, 8:37:43 AM9/3/20
to Roberto Franceschini, tmux-users
> Maybe I am just thinking about a configurable shortcut for certain windows, indest of having them bound to the standard 0-10 M-a to M-z.

And you can do this just by binding the keys to switch-client - but you will need to identify the windows in some way. If they are always in the same place or have a unique name you could just do:

tmux bind M-1 switch-client -t mysession:99

Or mysession:buildwindow if the name is always the same.

Alternatively you could mark them in some way eg with a user option, like set -w @buildwindow yes, then look for them with a script, something like:

W=$(tmux lsw -aF '#{@buildwindow} #{pane_id}'|awk '/^yes/ {print $2}')
[ -n "$W" ] && tmux switch-client -t $W



Roberto Franceschini

unread,
Sep 3, 2020, 8:38:20 AM9/3/20
to tmux-users
each session is for some general topic, i.e. system scripts, or jupyter kernels, or to collect something that is related to the same project (e.g. development-tmux).
in each session I have several repetitive tasks, which I like to have saved in separate bash_history, e.g. a complex compile command, a complex run command, a jupyter launch command which specifies a port number for that specific thing and its remembered by the shell (not by me) through the history, a series of folders each in one of the several git/svn repos I need to pull/push every now and then and I do not want to navigate to the right folder every time ... 

if you are managing a system, working on a few projects, and taking care of a few minor things that requires complex commands I guess is not hard to have 14 sessions and 6 or 7 windows in each.  

maybe there are better ways of organizing this, but I guess we are going into the specifics of my work habits, not of tmux use : ) I just wanted to support the case for a user having 100 windows not being such an impossible case of use of tmux.

Roberto Franceschini

unread,
Sep 3, 2020, 12:45:59 PM9/3/20
to tmux-users
fzf and dialog are new tools to me, thanks for pointing them out. for now I have managed to do something decent with a key binding to set the tag set -w @mysubset 'yes' and a key binding to get a tree of just the windows having the tag. I think for a few tags of not really fast-changing windows in the list it's the minimal friction and works quite effectively.
Reply all
Reply to author
Forward
0 new messages