I'm trying to write a bash script which will setup my tmux environment automatically. Essentially what I need to do is:

  1. Copy .tmux.conf from my repo
  2. Clone https://github.com/tmux-plugins/tpm into ~/.tmux/plugins/tpm
  3. Run tmux
  4. Execute <Prefix>-I in the tmux session (for me prefix is Ctrl-B)

Steps 1-3 are quite simple, but I don't know how to send a key sequence in bash to a terminal.


I tried running the following command:
tmux send-prefix -t 0; tmux send-keys -t 0 "I
but it didn't work. I got a following error:
I: command not found
.Any ideas on how to make it work?


1 Answer 1


The action #4 in your list ("Execute <Prefix>-I in the tmux session") is setup by tpm to run one of the scripts(update_plugin.sh) installed by tpm.

As such, you can just just call this script as part of your deployment script, instead of trying to inject the keystroke to trigger it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .