Programmatically send keys to session
dyamon opened this issue · comments
I'm trying to replace tmux with dvtm+abduco, but I just realized that one of the features I use doesn't seem to be present in the latter solution.
With tmux, I'm able to send keypresses to a session without being attached to it with the tmux send-keys
command. The command target is a session+window+pane but it seems like abduco doesn't know anything about windows/panes and dvtm doesn't know anything about sessions.
Is there a way to achieve this? Is it even feasible to implement something like this?
Something like abduco -c hi
and echo -n Hello | abduco -a hi
(in another shell)?
It works indeed, thanks! I thought the second command would attach the current shell to the hi
session, but this behavior actually makes more sense!
It’s thanked to the so called pass-through mode[*], but -p
can be omitted since stdin is not a tty in the above case.
You can read more (one sentence) about it in the manual page, but it’s certainly better to take a short glimpse into the source code so you will understand what’s going on. But at the end of the day it does what you need. :)
*: Data flows only from stdin->server, but not in the other way.
Thanks for the pointer!
Also, let's say that I want to to run some command command
in dvtm
on the 2nd window in the stack tagged with 3. I should be able to write a script that uses dvtm -c ...
to focus the right window, pipe command
into abduco -a ...
and maybe restore the original focus with dvtm -c
again.
Am I right?
Yes… you can do everything. You do not even need that two separate dvtm -c
calls because you (can) give commands to dvtm
with ... | abduco session
.
For example, assuming that your dvtm
modifier is C-g, you can do so: printf '\x07cecho Hello World\ndate\n\x07k' | abduco -a session
.
(Really just to make sure, when you wrote "pipe command into abduco -a", command
must generate keyboard input; so vi | abduco -a
is wrong.)
Oh ok, even better! Thank you very much.
Also looking at the abduco manpage I saw that one of the examples explains exactly how to send keypresses to a session. Sorry if the initial question was trivially answered by the manpage!
I think the issue can be closed.