Linux multi window terminal Screen and Tmux
Screen allows for multi window connection using a single ssh session. It also allows to detach from the session screen while still running a remote session.
Tmux
Sessions, windows, panes
Tmux is a so-called terminal multiplexer. Simply speaking, tmux acts as a window manager within your terminal1 and allows you to create multiple windows and panes within a single terminal window. Within one terminal window you can open multiple windows and split-views (called “panes” in tmux lingo). Each pane will contain its own, independently running terminal instance. This allows you to have multiple terminal commands and applications running visually next to each other without the need to open multiple terminal emulator windows.
The server holds sessions and the windows and panes within them:
- session - is a set of windows, plus a notion of which window is current,there may be multiple sessions on a server,
- window(tab) - is a single screen covered with panes, each session may have many separate windows that you can switch between
- pane - is a rectangular part of a window that runs a specific command, e.g. a shell
Install Tmux
- Install - linux - use package manager
sudo apt-get install tmux
- Install - Windows
- Install Git for Windows SDK
run /bin/pacman -S tmux
- Quick Start
/usr/bin/tmux
Managging sessions
tmux new -s database #start new session named 'database' tmux ls #lists all detached sessions tmux attach -t 0 #attach to terminal 0 session tmux rename-session -t 0 database tmux switch -t <session_name> tmux kill-session -t <session_name>
- Key bindings
C^b :new<CR>
new sessionC^b $
name sessionC^b (
previous sessionC^b )
next sessionC^b L
'last' (previously used) sessionC^b s
choose a session from a list
Key bindings
C^b c
create a window aka new virtual desktop, it creates a full size window on top of your panesC^b "
split a pane horizontlyC^b %
split a pane verticallyC^b z
full screen pane resize, repeat to get backC^d
close a pane, also type 'exit'C^b Up,Down,Left,Right arrow
move to neighbouring paneC^b q #index
display pane numbers, then press 0..9 to move to #paneIndexC^b 0-9
move to the window based on indexC^b [] {}
swap panes [] left-right, {} up-down swapC^b ,
rename the current windowC^b d
detach the current sessionC^b D
gives you a choice what session you wish to detach
- Screen navigation, scroll and search
Function vi emacs -------- -- ----- Half page down C-d M-Down Half page up C-u M-Up Next page C-f Page down Previous page C-b Page up Scroll down C-Down or C-e C-Down Scroll up C-Up or C-y C-Up Search again n n Search again in reverse N N Search backward ? C-r Search forward / C-s
Copy-paste default mode (Emacs style)
Ctrl+b,[ # enter 'copy mode' # navigate using arrows to text you want to start coping Ctrl+Space # start coping (highlighting) # move around using arrow keys to select region Ctrl+w or Alt+w # copy the region into the buffer Ctrl+b,] # paste in a possibly different Tmux pane/window C^b,:show-buffer # show current buffer
Tmux Resurrect
Restore tmux environment after system restart.
Tmuxinator
Create and manage tmux sessions easily.
Terminator
Terminator is user frendly, gui scalable terminal with layouts, multi windows, tabs and broadcast function
$ sudo apt install terminator
Useful key bindings
Alt+Arrow Move to another terminal C^+Shift+X Maximise current window, press again to revert C^+Shift+Z Zooms the current terminal, press again to revert C^+Shift+O Split terminals Horizontally. C^+Shift+E Split terminals Vertically. C^+Shift+Arrow Resize windows by moving parent dragbar C^+Shift+T Open new tab C^+Shift+PgUp Switch between tabs, PgDown in reverse order C^+Shift+W Close the current terminal. C^+Shift+Q Quit terminator C^+Plus (+) Increase font size. Note: this may require you to press shift, depending on your keyboard C^+Minus(-) Decrease font size. Note: this may require you to press shift C^+Zero Restore font size to original setting. Super+G Group all Super+Shift+G Ungroup all
Windows ComEmu
References
- User Guide HTML one page
- Tmux Official website
- tmux cheat sheet TOP CLASS!
- Terminator Key bindings man page