read

tmux has become more useful whenever I need to SSH from my mobile device to my main running computer. Here are some frequently used commands.

Create a new session

Provide your session name, eg. “mayday”

tmux new -s mayday

With that you can list list all the sessions

tmux ls

Attach to the session

tmux attach -t mayday

Bonus: To be the single controller and detaching all others, add a -d flag.

Create/Attach

Probably the best way is to create if needed, else attach

tmux new -As mayday

Detach from the session

Since you’re already in the tmux session, you don’t issue a command, but press Ctrl+b then d (detach).

Terminate a session

While detach still keeps the session alive, to really teminate it you have to kill it.

tmux kill-session -t mayday

Pane Management

Ctrl+b first, then

  • Split pane with % (vertically) or " (horizontally)
  • Jump to next pane o, zoom pane z, kill pane x
  • Enter copy/scroll mode [

Send keys

Send key strokes directly to a session, great for automation:

tmux send-keys -t mayday 'npm run dev' C-m

The C-m is sending Enter.


Image

@samwize

¯\_(ツ)_/¯

Back to Home