I’m trying to automate the setup of my development environment using a tmux script. The script creates a new tmux session named Foo, splits the windows, sets the working directories, and sends commands to the panes. However, the send-keys commands are not working unless I add a display-message command to the script which seems weird.
#!/bin/bash
tmux new-session -d -s Foo -c ~/code/bar
tmux split-window -h -c ~/code/bar
tmux split-window -v -c ~/code/bar
# These are the issue
tmux send-keys -t Foo:zsh.1 "vim" ENTER
tmux send-keys -t Foo:zsh.2 "npm run dev" ENTER
# If this is not included, the above two commands don't work
tmux display-message -p "Window: #W, Pane: #P"
tmux attach -t Foo