Reputation: 5210
I have the following script:
#!/bin/sh
tmux new-session -d -s vim 'vim index.js'
tmux split-window -h 'nodemon index.js'
tmux -2 attach-session -d
My goal is to have a tmux session open with vim in left pane and nodemon running in the right. This seems to start up fine, but then stops and the right pane closes after a few seconds.
Additionally I'd like to have it set the cursor in the left pane on start.
Any help would be greatly appreciated.
Upvotes: 0
Views: 661
Reputation: 15400
Problem is that you have bound pane to a command. Which means when you close command the pane will close too. Use different approach. Open pane and then send-keys
to open desired command
#!/bin/sh
tmux new-session -d -s vim
tmux send-keys -t vim:.1 'vim index.js' Enter
tmux split-window -h
tmux send-keys -t vim:.2 'nodemon index.js' Enter
# select pane
tmux select-pane -t vim:.2
tmux -2 attach-session -d
Note: Also you could look into https://github.com/tmuxinator/tmuxinator
Upvotes: 1