finding correct tmux send keys to custom socket and session syntax

I have attempted to get the syntax of the send keys argument correct and tried a few variations I tried to piece together from the man page but I must simply be misunderstanding something.

I initialize tmux in the following manner and wish to manipulate it as seen below.

sudo -H -u username1 -g usergroup1 bash -c '/usr/bin/tmux -S /home/shares/tmux_sessions/sock_file new -d -s "sess-tv0-i" mycommand -arg1 -arg2'
sudo -H -u username1 -g usergroup1 bash -c '/usr/bin/tmux -S /home/shares/tmux_sessions/sock_file new -d -s "sess-tv1-i" mycommand -arg1 -arg2'
sudo -H -u username1 -g usergroup1 bash -c '/usr/bin/tmux -S /home/shares/tmux_sessions/sock_file new -d -s "sess-tv2-i" mycommand -arg1 -arg2'

I attempt to send keys to an individual session however my command below seems to send the command to all sessions which is undesired, i wish to send keys to only 1 session at a time.

tmux -S /home/shares/tmux_sessions/sock_file send-keys C-c -t sess-tv0-i

Using the above command gives no error however as stated it does send that keystring to multiple sessions in that socket.

I have also tried the following below with failure.

tmux -S /home/shares/tmux_sessions/sock_file target-session -t sess-tv0-i send-keys C-c
unknown command: target-session
tmux target-session -t sess-tv0-i send-keys C-c
error connecting to /tmp/tmux-0/default (No such file or directory)
tmux -S /home/shares/tmux_sessions/sock_file -t sess-tv0-i send-keys C-c
tmux: unknown option -- t
usage: tmux [-2CluvV] [-c shell-command] [-f file] [-L socket-name] [-S socket-path] [command [flags]]

Thanks for any advice or for pointing me in the right direction.

1 Answer

Apparent error was using

tmux -S /home/shares/tmux_sessions/sock_file send-keys C-c -t sess-tv0-i

which would send the C-c or Control+c keys to all sessions in that sock-file instead of using

tmux -S /home/shares/tmux_sessions/sock_file send-keys -t sess-tv0-i C-c

which allows the -t flag to properly be assessed.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like