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

Feature: enable -F format string option to show custom information for panes in display-panes command #3074

Closed
poetaman opened this issue Feb 18, 2022 · 10 comments

Comments

@poetaman
Copy link

poetaman commented Feb 18, 2022

Issue description

Currently display-pane shows the pane size on the top right corner of the panes. It would be nice to have a way to specify a format string just like for many other commands that would print custom information for each pane. As a corollary bonus, tmux would figure out the size of longest line in the format string, and pad every line of format string to be right aligned, as shown in example below.

Example:

tmux display-panes -F "pane_id: #{pane_id}\n pane_pid: #{pane_pid}\n ..."

would print:

_______________________________________________
                              pane_id: 1      |
                              pane_pid: 23434 |
                              ...             |
                                              |
                                              |
                                              |
_______________________________________________
@poetaman poetaman changed the title Feature: enable -F format string option to show custom information for panes Feature: enable -F format string option to show custom information for panes in display-panes command Feb 18, 2022
@ThomasAdam
Copy link
Contributor

Considering we've already got other commands to display custom information, and now popup windows, etc., is this really going to be useful?

@poetaman
Copy link
Author

poetaman commented Feb 24, 2022

@ThomasAdam Yes in the sense that if user has 4 panes open, it will show all the 4 pane's information together. It will be helpful while debugging tmux plugins at the very least.

Haven't tried sending stdout to all tmux panes together, maybe that is possible. A problem or intend behavior today with sending stdout to tmux pane is it doesn't respect coloring done with escape sequences (and ends up showing escape sequences instead). Maybe one can write a script that cycles through panes of current window, and sends stdout to print all the info. Though that won't overlay over the pane contents either like display-panes does...

For example: echo -e "\033[31;1;4mHello\033[0m" sent as stdout to tmux pane does not color Hello, instead shows the entire raw string with escape sequences.

@nicm
Copy link
Member

nicm commented Feb 28, 2022

Added this to todo list, although I don't think I would make it support newlines.

@nicm nicm closed this as completed Feb 28, 2022
@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 Mar 31, 2022
@afh
Copy link

afh commented Aug 17, 2023

I'd like to learn more about your use-case, @poetaman. Could elaborate a bit more how you'd like to use the proposed feature and what additional value it would bring over list-panes, e.g.:

% tmux list-panes -F 'pane_id: #{pane_id}, pane_pid #{pane_pid}'
pane_id: %107, pane_pid 44545
pane_id: %108, pane_pid 44663

@afh afh reopened this Aug 17, 2023
@nicm
Copy link
Member

nicm commented Aug 18, 2023

It's just an option to control the text shown when you do display-panes in the top right of the pane, currently this is fixed to the pane size.

@afh
Copy link

afh commented Aug 18, 2023

Right, so this is very similar to list-panes yet the information presented is presented at the top of each pane, which places the information visually closer to its origin.

What are your objects towards supporting newlines, @nicm? I noticed that other format strings in tmux do not support these either…

@nicm
Copy link
Member

nicm commented Aug 18, 2023

It would be much more complicated to make newlines work and it seems unnecessary here.

@nicm
Copy link
Member

nicm commented Aug 18, 2023

You would need to add display-panes-format and store its value in cmd_display_panes_data, then change cmd_display_panes_draw_pane to use format_draw to a temporary screen (you can make it the full width of the pane) and then copy that to the terminal with tty_draw_line (similarly to how menu_draw_cb draws to a temporary screen). This would replace the rbuf drawn with tty_putn.

@nicm
Copy link
Member

nicm commented Aug 18, 2023

The default display-panes-format can be something like #[align=right fg=#{?pane_active,#{display-panes-active-colour},#{display-panes-colour}}]#{pane_width}x#{pane_height}.

@nicm nicm closed this as completed Oct 14, 2023
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

4 participants