Limitation on menu items depth

37 views
Skip to first unread message

Timur

unread,
Aug 16, 2024, 3:15:01 PM8/16/24
to tmux-users
Hi!
I am trying to figure out a solution for creating a menu, with (in theory) indefinite amount of nested items, but it logically fails to work in a single command

The moment i realized, that you can feed keystrokes into the terminal and there is a relatively simple way of creating menus, i immediately thought of binding a set of frequently used commands to a menu items, which has proven to be decently comfortable doing routine operations.

Consequently, the list of commands (or mostly just set of keys and control characters) has been growing, and it became obvious, that it will be much easier to distribute commands by their logical "belonging" (like for database or logs scraping) to its own menu item, where each of them will be opening "next menu". First approach was to create a set of bash scripts, where each of them will create menu, while items of a "first menu" only calling those scripts. Recently, it started to be quite exhausting to edit or add new items, which inspired me to write a script, which will compose a single command, based on the file (with its own syntax), where each menu item described.

Turns out, that a single tmux display-menu command is reasonably limited.
First layer is quite easy to accomplish, but specifying a display-menu as one of the commands of a menu item require to pass all further arguments in a single string.
For example:
display-menu 'first layer' none 'display-menu "second layer" none "send-keys \"some keys\""'
Second layer already causes some complications for certain characters to be sent in "send-keys", but it can be bypassed using something that i certainly do not have name for: "escaping out of the main string" - "\'" \\special_char "\'"
Escaping a single quote inside of the double quotes in order to tell tmux to treat this quote not as the end of send-keys string is already too much, but works!

Is there a way to query a tmux to create a menu with more than two levels deep? Third level in a single command would be a string, that is already in a string of an outer menu, where a whole send-keys needs to be quoted, while keys to be sent is also needs to be separately quoted. I am sure there is a deeply undocumented ways of doing something like that, and it probably can be put in a for loop with 0 readability, but would be glad to hear, if there are any plans for improving menus functionality. Or any other ways of implementing nested menu items using only tmux, without any external code to create them

Nicholas Marriott

unread,
Aug 19, 2024, 4:40:18 AM8/19/24
to Timur, tmux-users
Put the second display-menu in a separate config file or in script? Or use {} instead of quotes and you should not need to escape?



--
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/b1240c78-93ef-4d78-bdf1-cb5a4f30049bn%40googlegroups.com.

Timur

unread,
Aug 19, 2024, 11:51:28 PM8/19/24
to tmux-users
Using {} seems to be working exactly as i expected! Entering this in the command-prompt creates quite deep set of menus:
menu 'first layer' none {menu "second layer" none {menu "third layer" none {menu "fourth layer" none {menu "fifth layer" none {menu "sooo deep" none split-window}}}}}
Thanks a lot!

понедельник, 19 августа 2024 г. в 11:40:18 UTC+3, Nicholas Marriott:
Reply all
Reply to author
Forward
0 new messages