Tmux

2024

Basics

  • Create a new session name abc

tmux new -s abc -d
  • View current sessions

tmux ls
  • Create a new windows num 10 name shell10 associated with a session

tmux new-window -t abc:10 -n shell10
  • Send work in the windows 10

tmux send-keys -t "abc:10" vim Enter
tmux send-keys -t "abc:10" "cd / ; ls -la ; cd -" Enter
  • Attached to the abc session

tmux attach -t abc
  • Send a command to all panes

Ctrl-B :

setw synchronize-panes on

clear history

Scripting

  • First script with tmux, the gold is to run multi-tasks interactively

tmux new -s abc -d
for i in {1..10}; do
    tmux new-window -t abc:$i -n "shell$i"
    tmux send-keys -t "abc:$i" "cd / ; ls -la ; cd -" Enter
done