This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
other:tmux_terminal_multiplexing [2021/04/02 18:36] nanodano |
other:tmux_terminal_multiplexing [2022/03/23 16:27] (current) nanodano |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Tmux Terminal Multiplexing ====== | ====== Tmux Terminal Multiplexing ====== | ||
- | [[https:// | + | [[https:// |
===== Installing ===== | ===== Installing ===== | ||
Line 46: | Line 46: | ||
tmux list-commands | tmux list-commands | ||
# Within tmux press '' | # Within tmux press '' | ||
+ | </ | ||
+ | |||
+ | ===== Enabling mouse ===== | ||
+ | |||
+ | With mouse enabled, you can click between split windows and use the mouse to resize. You can also right click on panes and in the bottom left corner to switch windows and manage processes. It adds a lot of really nice functionality. | ||
+ | |||
+ | You must specify '' | ||
+ | |||
+ | <code - .tmux.conf> | ||
+ | # ~/ | ||
+ | |||
+ | # Enable mouse | ||
+ | set -g mouse on | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | # Then run tmux as normal | ||
+ | tmux | ||
+ | # OR to be explicit | ||
+ | tmux source-file ~/ | ||
</ | </ | ||
Line 63: | Line 83: | ||
# Create a new named session | # Create a new named session | ||
- | tmux new -s "mysession" | + | tmux new -s mysession |
+ | |||
+ | # Create a new named session + run vim in detached mode | ||
+ | tmux new -s mysession -d "vim" | ||
# Connect to a session by name | # Connect to a session by name | ||
- | tmux attach -t "mysession" | + | tmux attach -t mysession |
</ | </ | ||
Once you are in a session and you want to disconnect, | Once you are in a session and you want to disconnect, | ||
- | < | + | < |
# Use the shell command | # Use the shell command | ||
tmux detach | tmux detach | ||
Line 77: | Line 100: | ||
# Or use the keybinds | # Or use the keybinds | ||
CTRL-b d | CTRL-b d | ||
+ | </ | ||
+ | |||
+ | To kill a session, simply exit the shell like normal with '' | ||
+ | |||
+ | <code bash> | ||
+ | # End a session by name | ||
+ | tmux kill-session -t myapp | ||
</ | </ | ||
===== Windows ===== | ===== Windows ===== | ||
+ | The top level object is a session. A session contains windows, and a window contains panes. Here are commands related to windows. Like most things in tmux, you can use the shell command, or the keybind. | ||
+ | |||
+ | <code bash> | ||
tmux new-window | tmux new-window | ||
tmux list-windows | tmux list-windows | ||
Line 90: | Line 123: | ||
tmux swap-pane -\[UDLR\] | tmux swap-pane -\[UDLR\] | ||
+ | </ | ||
+ | Most of these keybinds must be preceeded with the '' | ||
- | Create a new window - '' | + | * Create a new window - '' |
- | List window - '' | + | |
- | Select a window - (the number of the window) | + | |
- | Rename windows - , | + | |
- | Kill window - & | + | |
- | Next window - n | + | |
- | Previous window - p | + | |
- | Last window - l | + | |
- | Split window horizontally in two panes - " | + | |
- | Split window vertically in to two panes - % | + | |
- | + | | |
- | Set even split horizontally - ALT-1 | + | |
- | Set even split vertically - ALT-2 | + | |
===== Panes ===== | ===== Panes ===== | ||
+ | A pane is the lowest level of hierarchy in screen organizing. The top level is the session, then the session has windows, and a window is made up of panes. | ||
- | Switch active pane - up/ | + | Most of these need to be preceeded by '' |
- | Next pane - o | + | |
- | Previous pane - ; | + | |
- | Kill pane - x | + | |
- | Break out pane in to window - ! | + | |
- | Resize pane 1 unit - CTRL- plus left/ | + | |
- | Resize pane 5 units - ALT- plus left/ | + | |
- | Swap pane up/down - { or } | + | |
- | Rotate pane up/down - CTRL-o or ALT-o | + | |
- | ===== Common keybinds | + | * Switch active pane - '' |
+ | * Next pane - '' | ||
+ | * Previous pane - '';'' | ||
+ | * Kill pane - '' | ||
+ | * Break out pane in to window - '' | ||
+ | * Resize pane 1 unit - '' | ||
+ | * Resize pane 5 units - '' | ||
+ | * Swap pane up/down - '' | ||
+ | * Rotate pane up/down - '' | ||
+ | |||
+ | |||
+ | |||
+ | ===== Send keystrokes to a session ===== | ||
+ | |||
+ | You can use '' | ||
+ | |||
+ | All keys including functions, alt, home, page up, arrow keys, and even mouse actions can all be emulated. Here is a full list of keys from the source code of tmux: | ||
+ | [[https:// | ||
+ | |||
+ | <code bash> | ||
+ | # Send some vim commands to a session | ||
+ | tmux send-keys -t mysession " | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Other common tasks ===== | ||
Every command is assumed to begin with the chord, which by default is '' | Every command is assumed to begin with the chord, which by default is '' | ||
Line 126: | Line 178: | ||
* Toggle scrolling with '' | * Toggle scrolling with '' | ||
- | * Switch to next pre-defined layout: '' | + | * Switch to next pre-defined layout: '' |
+ | |||
+ |