I'm having problems putting "send-keys" into a bash function. Here's a minimal example:
function keys {
tmux send-keys -t work:1 $*
}
tmux new-session -d -s work
keys "pwd" c-m "ls -latr" c-m
tmux attach-session -t work
The keys argument here is exactly what I'd type on the command-line as an argument to tmux send-keys
. It almost works, but strips spaces, so I see ls-latr
all as one word. But if I put quotes around the $*
in the function, it just outputs the entire keys argument on one line (treating the c-m
as literal characters). How could I make it execute the send-keys argument as if I'd typed it from command-line?