Create session with a name
tmux new -s <name>
Create detached session with a name
This particular example will run SimpleHTTPServer in the background:
tmux new -s python -d 'python -m SimpleHTTPServer'
To kill it programatically:
kill -9 `top -n 1 | pgrep tmux`
Attach to session with name
tmux attach -t <name>
List sessions
tmux ls
# or from within a tmux session:
ctrl+b s
Background session
ctrl+b d
Rename current session
ctrl+b $
Kill session
tmux kill-session -t <name>
Background session on remote host and close ssh session
return ~ .
Resources
https://gist.github.com/henrik/1967800
Screen splitting
Horizontal split:
ctrl-b "
Vertical split:
ctrl-b %
Resources:
https://gist.github.com/MohamedAlaa/2961058
Use tmuxinator for environment automation
Great tutorial here: https://collectiveidea.com/blog/archives/2017/03/27/using-tmuxinator-to-automate-your-environment
Use mouse to copy and paste in a pane
In iTerm2:
- Hold down the Option key and the alt key
- Drag your mouse with the left click to select a body of text in a particular pane
Use Command-c to copy and Command-v to paste
Show Help Menu
C-b C-/
Scroll up
Type this command in:
ctrl-b [
At this point you can use things like your arrow keys and page up/page down, etc.
Resource: https://superuser.com/questions/209437/how-do-i-scroll-in-tmux