I want tmux to open a new window and then cd into a directory, but it doesn't work. It just opens tmux in the directory my script was run from (ie. it doesn't execute the cd command).
Can someone tell me what I'm doing wrong? (I'm using tmux 1.6)
#!/bin/bash
tmux start-server
tmux new-session -d -s my_server -n runstuff
tmux send-keys -t my_server:1 "cd /etc"
tmux select-window -t my_server:1
tmux attach-session -t my_server
I finally got it to work, using C-m and numbering the windows starting from 0. I added a second command for illustrative purposes.
#!/bin/bash
tmux start-server
tmux new-session -d -s my_server -n runstuff
tmux new-window -t my_server:1 -n someotherjunk
tmux send-keys -t my_server:0 "cd /etc" C-m
tmux send-keys -t my_server:1 "./yolo" C-m
tmux select-window -t my_server:runstuff
tmux attach-session -t my_server
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With