Lets say I have
top or some ncurses program running in a graphical terminal, and from outside this terminal I'd like to execute a command, that would replace
top with another program of my choosing.
I imagine there to be a generic approach to this, something that
- finds the PTY for the correct window
- kills the program in the terminal, while keeping the PTY
- Spawns the replacement command, and
- hooks up PTY I/O to read/write to/from the command
My googling for preexisting generic solutions to wrap this has not yielded useful pointers.
The specific use-case I have for this: I want to switch the tmux client running in gnome-terminal from one /tmp/tmux-$UID/Socket (=server) to another one belonging to the same user, without "losing" the window.
I'm looking for the generic solution, because I could not get a connected tmux-client to connect/attach to a new socket at run-time.