Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

choose-window sorely missing #2636

Closed
gregrwm opened this issue Apr 6, 2021 · 13 comments
Closed

choose-window sorely missing #2636

gregrwm opened this issue Apr 6, 2021 · 13 comments

Comments

@gregrwm
Copy link

gregrwm commented Apr 6, 2021

Issue description

Ah, the sweet memories, i'm doing a bit of work on centos7, with tmux of same vintage, see how the window indexes all line up nicely! They're not all off-by-one, and the windows beyond 9 can be selected by a single letter!

(0)   0: bash- [226x57] (1 panes) "caper.fo4.net"                                                                                                                                                                                 
(1)   1: bash  [226x57] (1 panes) "caper.fo4.net"                                                                                                                                                                                 
(2)   2: ssh  [226x57] (1 panes) "caper.fo4.net"                                                                                                                                                                                  
(3)   3: ssh  [226x57] (1 panes) "caper.fo4.net"                                                                                                                                                                                  
(4)   4: bash  [226x57] (1 panes) "caper.fo4.net"                                                                                                                                                                                 
(5)   5: ssh  [226x57] (1 panes) "caper.fo4.net"                                                                                                                                                                                  
(6)   6: bash  [226x57] (1 panes) "caper.fo4.net"                                                                                                                                                                                 
(7)   7: bash  [226x57] (1 panes) "caper.fo4.net"                                                                                                                                                                                 
(8)   8: ssh  [226x57] (1 panes) "caper.fo4.net"                                                                                                                                                                                  
(9)  14: sudo  [226x57] (1 panes) "caper.fo4.net"                                                                                                                                                                                 
(a)  15: bash  [226x57] (1 panes) "caper.fo4.net"                                                                                                                                                                                 
(b)  18: sudo  [226x57] (1 panes) "caper.fo4.net"                                                                                                                                                                                 
(c)  19: sudo  [226x57] (1 panes) "caper.fo4.net"                                                                                                                                                                                 
(d)  21: sudo* [226x57] (1 panes) "caper.fo4.net"

i know choose-tree is wonderful, but can we perchance please also have choose-window back the way it was?

it's a daily disappointment having to work with this instead:

(0)   - 0: 13 windows (attached)
(1)   ├─> 0: bash
(2)   ├─> 1: bash
(3)   ├─> 2: ssh
(4)   ├─> 3: bash
(5)   ├─> 4: ssh-
(6)   ├─> 5: ssh
(7)   ├─> 6: [tmux]*                                                                                                                                                                                                              
(8)   ├─> 7: ssh
(9)   ├─> 8: bash
(M-a) ├─> 10: ssh
(M-b) ├─> 11: screen
(M-c) ├─> 12: top
(M-d) └─> 93: bash
@nicm
Copy link
Member

nicm commented Apr 7, 2021

It's not coming back, sorry. You can make concrete suggestion for changes to choose-tree if you like.

@gregrwm
Copy link
Author

gregrwm commented Apr 7, 2021

Choose-tree could indeed be great if there were a way to filter out, or opt out from the session line at the top, or give it something other than a digit, so the window indexes below it are no longer off-by-one.

For example, it would be great if the list choices 0-9 would always correspond to window indexes 0-9, even if some of those windows aren't currently active. Then any windows indexes 10 or above could be listed with simple lowercase letters. The top session line could be M-a, another session could be M-b, etc.

@nicm
Copy link
Member

nicm commented Apr 7, 2021

We can't use lowercase letters because they are used for commands, that isn't going to change.

Not sure about removing the session line, perhaps that is possible.

It might be possible to bind keys to windows rather than just to the item on that line.

@gregrwm
Copy link
Author

gregrwm commented Apr 8, 2021

how about if choose-tree would prefer to match up 0-9 with window indexes 0-9 as far as possible, and list everything else as M-a etc, even tho M-a might then be at the top, and M-b might be right after window 9?

@nicm
Copy link
Member

nicm commented Apr 8, 2021

Right, that's what I means by binding keys to windows.

@gregrwm
Copy link
Author

gregrwm commented Apr 9, 2021

in the below situation, it's very nice to match up 1 with window 1, and great to go ahead and use 2-9 for other windows, as choose-tree is already doing:

(0)   - 0: 14 windows (attached)
(1)   ├─> 1: bash
(2)   ├─> 33: ssh
(3)   ├─> 43: ssh
(4)   ├─> 50: ssh
(5)   ├─> 52: ssh
(6)   ├─> 55: ssh
(7)   ├─> 56: ssh
(8)   ├─> 59: [tmux]*                                                                                                                                                                                                             
(9)   ├─> 63: ssh
(M-a) ├─> 73: ssh
(M-b) ├─> 76: ssh
(M-c) ├─> 77: ssh-
(M-d) ├─> 82: ssh
(M-e) └─> 89: ssh

@gregrwm
Copy link
Author

gregrwm commented Apr 9, 2021

given this assortment of windows, this choose-tree list would be the most convenient and sensible, making the best possible use of the digits 0-9:

(M-a) - 0: 14 windows (attached)
(2)   ├─> 2: bash
(5)   ├─> 5: ssh
(0)   ├─> 22: ssh
(1)   ├─> 23: ssh
(3)   ├─> 43: ssh
(4)   ├─> 50: ssh
(6)   ├─> 55: ssh
(7)   ├─> 56: ssh
(8)   ├─> 59: [tmux]*                                                                                                                                                                                                             
(9)   ├─> 63: ssh
(M-b) ├─> 76: ssh
(M-c) ├─> 77: ssh-
(M-d) ├─> 82: ssh
(M-e) └─> 89: ssh

@nicm
Copy link
Member

nicm commented Apr 9, 2021

I like the existing shortcut scheme, so we need any change to be optional so this can remain the default. Additionally it is likely that people who want to map by window_index for -w will not want the same for -s.

We could do it though a format. For example, we could say that if the format evaluates to a number then the line is assigned that key (0 = 0, 10 = M-a); if it evaluates to empty then it gets the next free key after all the other lines are assigned; or possibly some other syntax that would allow >10 to be ordered as well. This means the default could be #{line} and for window assignment only something like #{?window_format,#{?#{e|<:#{window_index},10},#{window_index},},}. We may need to introduce some additional format variables to be useful (for example, a way to convert a session name into a position in the sorted list of all sessions, or similar for windows).

Or perhaps this is being too complicated. Hardly anyone wants to change this so perhaps we make a few fixed choices (line, window-index, session-name etc), like the sort order.

@nicm
Copy link
Member

nicm commented Apr 9, 2021

Try this please: tmux-key-format.diff.txt

tmux choose-tree -K "#{?window_format,#{?#{e|<:#{window_index},10},#{window_index},#{?#{e|<:#{window_index},36},#{a:#{e|+:#{e|-:#{window_index},10},97}},}},}"

@gregrwm
Copy link
Author

gregrwm commented Apr 9, 2021

i like it. single digits match single digit indexes. single keystroke for other windows. thank you!

@gregrwm gregrwm closed this as completed Apr 10, 2021
@nicm
Copy link
Member

nicm commented Apr 12, 2021

Applied to OpenBSD now, will be in GitHub later. Thanks!

@nicm
Copy link
Member

nicm commented Apr 12, 2021

This is a better format which only assigns keys to windows in the current session: https://github.com/tmux/tmux/wiki/Recipes#change-shortcut-keys-in-tree-mode

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants