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

[REQUEST] revert f26d4ea4 for putting tmux into background again #5177

Open
Yukaii opened this issue May 14, 2024 · 7 comments
Open

[REQUEST] revert f26d4ea4 for putting tmux into background again #5177

Yukaii opened this issue May 14, 2024 · 7 comments

Comments

@Yukaii
Copy link
Contributor

Yukaii commented May 14, 2024

Feature

I actually found running tmux in the background useful when using tools like kks along with tmux popup.

Unlike the description in commit f26d4ea about split-window, tmux display-popup is a long-running process and needs to be put into the background.

People using kakoune with tmux-popup like me can define an old overwrite command for tmux-terminal-impl:

https://github.com/Yukaii/dotfiles/blob/8ec32679c4c154b45b048bc7fca02e38cc5d1ba3/kakoune/.config/kak/tmux.kak#L36-L59

I have defined a custom tmux command called tmux-popup as follows:

define-command tmux-popup -params 1.. -docstring '
tmux-popup <program> [<arguments>]: create a new terminal as a tmux popup
The program passed as an argument will be executed in the new terminal' \
%{
    tmux-terminal-impl "popup -w 90%% -h 80%% -E -d %val{client_env_PWD}" %arg{@}
}
complete-command tmux-popup shell
2024-05-14.10.53.09.mp4

Spent some time to get my kks setup working again after this release. 😂

Usecase

  • Use with tmux display-popup
@Yukaii
Copy link
Contributor Author

Yukaii commented May 14, 2024

The other solution might be to create a standalone tmux-popup command that doesn't depend on tmux-terminal-impl. The split-window stays the current behavior, while tmux-popup runs in the background.

@krobelus
Copy link
Contributor

krobelus commented May 14, 2024

Reverting sounds fine. If we had never added the backgrounding behavior, I'd have doubts about adding it because users can always copy tmux-terminal-impl. But since it already worked, it seems better to keep it working.

Out of curiosity, with tmux-popup, how do you make it so you can focus other tmux windows/panes while the popup is showing?
My C-b is being ignored and forwarded to the program running in the popup.

@Yukaii
Copy link
Contributor Author

Yukaii commented May 15, 2024

how do you make it so you can focus other tmux windows/panes while the popup is showing?

I cannot either 😅. I use popups as disposable windows.

For persistent actions like a floating terminal or keeping a lazygit process open, I actually wrote a script to create and automatically attach another tmux session on a popup display.

https://github.com/Yukaii/dotfiles/tree/macos-m3/bin#tmux-popup

Demo

311580080-d901b69d-81b1-4379-937a-66c007f525ca.mp4

@krobelus
Copy link
Contributor

Is there a use case where one wants to be notified once the popup is closed?
I guess there are but probably not so important

@krobelus
Copy link
Contributor

krobelus commented May 15, 2024

something like

tmux-terminal-impl display-popup -E -E sh -c 'sleep 1; date >/tmp/result'
echo %file{/tmp/result}

I guess that's a rare use case, especially given we can't pass $kak_command_fifo to tmux-terminal-impl args

@Yukaii
Copy link
Contributor Author

Yukaii commented May 16, 2024

Is there a use case where one wants to be notified once the popup is closed?
I guess there are but probably not so important

Maybe a non-windowing command like tmux list-session? For me, since tmux-terminal-impl is specifically implemented for windowing commands, vertical/horizontal/popup should behave in the same way. For other tmux commands, people should use regular shell commands.

@krobelus
Copy link
Contributor

looking closer at tmux-terminal-impl, it seems that it only works properly for the split-* and new-window commands.
For other commands, when using multiple tmux sessions, tmux-terminal-impl will operate in the session that created the kak server, not in the session of the calling kak client.
(see 0fb99f2 (tmux.kak: use TMUX_PANE for tmux-terminal-{horizontal,vertical}, 2020-07-26))
We want to do something similar for popup.

Since we'll already want popup-specific code we can add backgrounding logic for that case only?
I asked on the tmux-users list why "tmux popup" blocks, would be interesting to know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants