Difference between revisions of "Linux multi window terminal Screen and Tmux"
(58 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
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. | 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. | ||
= Install Screen = | = Tmux = | ||
== Sessions, windows(aka tabs) and 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 | |||
Indicator, bottom left conrner | |||
<source> | |||
[0] 0:bash- 1:bash* | |||
# currently looking at 'tab 1' of tmux window(tab) '0'. | |||
</source> | |||
:[[File:ClipCapIt-190810-144653.PNG]] | |||
== Install Tmux == | |||
;Install - Linux via package manager | |||
* <source lang="bash" inline>sudo apt-get install tmux</source> | |||
;Install - Windows | |||
* Install [https://github.com/git-for-windows/build-extra/releases Git for Windows SDK] | |||
* <source inline>run /bin/pacman -S tmux</source> | |||
;Quick Start | |||
<source lang="bash"> | |||
/usr/bin/tmux | |||
</source> | |||
;Auto completion [1] | |||
<source lang=bash> | |||
wget -q https://github.com/imomaliev/tmux-bash-completion/raw/master/completions/tmux -O ~/.bash_completion_tmux | |||
# add to ~/.bashrc | |||
echo "source ~/.bash_completion_tmux" >> ~/.bashrc | |||
</source> | |||
;References | |||
* [1] - https://github.com/imomaliev/tmux-bash-completion | |||
== Managging sessions == | |||
<source lang="bash"> | |||
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> | |||
</source> | |||
;Key bindings | |||
*<code>C^b :new<CR></code> new session | |||
*<code>C^b $</code> name session | |||
*<code>C^b (</code> previous session | |||
*<code>C^b )</code> next session | |||
*<code>C^b L</code> 'last' (previously used) session | |||
*<code>C^b s</code> choose a session from a list | |||
== Key bindings == | |||
;Windows(aka tabs) | |||
*<code>C^b c</code> create new window(aka tab), creates a full size window on top of your panes | |||
*<code>C^n c</code> switch to next window(aka tab) | |||
*<code>C^p c</code> switch to previous window(aka tab) | |||
*<code>C^l c</code> switch to last window(aka tab) | |||
*<code>C^b ,</code> rename current window | |||
*<code>C^b d</code> detach current session | |||
*<code>C^b D</code> gives you a choice what session you wish to detach | |||
;Pane | |||
*<code>C^b "</code> split a pane horizontally | |||
*<code>C^b %</code> split a pane vertically | |||
*<code>C^b z</code> full screen pane resize, repeat to get back | |||
*<code>C^d</code> close a pane, also type 'exit' | |||
*<code>C^b Up,Down,Left,Right arrow</code> move to neighbouring pane | |||
*<code>C^b q #index</code> display pane numbers, then press 0..9 to move to #paneIndex | |||
*<code>C^b 0-9</code> move to the window based on index | |||
*<code>C^b [] {}</code> swap panes '''[]''' left-right, '''{}''' up-down swap | |||
;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) == | |||
<source> | |||
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 | |||
</source> | |||
== Commands == | |||
<source> | |||
C^b, :setw synchronize-panes on | |||
C^b, :setw synchronize-panes off | |||
</source> | |||
== Tmux Plugin Manager == | |||
Clone TPM | |||
<source lang=bash> | |||
$ git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm | |||
</source> | |||
Put this at the bottom of <code>~/.tmux.conf</code> (<code>$XDG_CONFIG_HOME/tmux/tmux.conf</code> works too): | |||
<source lang=bash> | |||
# List of plugins | |||
set -g @plugin 'tmux-plugins/tpm' | |||
set -g @plugin 'tmux-plugins/tmux-resurrect' | |||
# set -g @plugin 'tmux-plugins/tmux-sensible' | |||
# Other examples: | |||
# set -g @plugin 'github_username/plugin_name' | |||
# set -g @plugin 'git@github.com/user/plugin' | |||
# set -g @plugin 'git@bitbucket.com/user/plugin' | |||
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) | |||
run -b '~/.tmux/plugins/tpm/tpm' | |||
</source> | |||
Reload TMUX environment so TPM is sourced: | |||
<source lang=bash> | |||
# type this in Tmux terminal if tmux is already running | |||
$ tmux source ~/.tmux.conf | |||
</source> | |||
That's it! | |||
;Installing plugins | |||
#Add new plugin to <code>~/.tmux.conf</code> with <code>set -g @plugin '...'</code> | |||
#Press prefix + I (capital i, as in Install) to fetch the plugin. | |||
You're good to go! The plugin was cloned to <code>~/.tmux/plugins/</code> dir and sourced. | |||
;Uninstalling plugins | |||
#Remove (or comment out) plugin from the list. | |||
#Press <code>prefix + alt + u</code> (lowercase u as in uninstall) to remove the plugin. | |||
All the plugins are installed to ~/.tmux/plugins/ so alternatively you can find plugin directory there and remove it. | |||
==[https://github.com/tmux-plugins/tmux-resurrect Tmux Resurrect]== | |||
Restore tmux environment after system restart. | |||
;Installation with Tmux Plugin Manager (recommended) | |||
Add plugin to the list of TPM plugins in <code>.tmux.conf</code>: | |||
<source> | |||
set -g @plugin 'tmux-plugins/tmux-resurrect' | |||
</source> | |||
Hit <code>prefix + I</code> to fetch the plugin and source it. You should now be able to use the plugin, no restart required. | |||
Key bindings | |||
* <code>prefix + Ctrl-s</code> - save | |||
* <code>prefix + Ctrl-r</code> - restore | |||
==[https://github.com/tmuxinator/tmuxinator Tmuxinator]== | |||
Create and manage tmux sessions easily. | |||
= Screen = | |||
sudo apt-get install screen | sudo apt-get install screen | ||
== Key terms == | == Key terms == | ||
* window -it's a separate window that you can switch between | * '''window''' - it's a separate window that you can switch between | ||
* region -your terminal screen can be divided in regions where each can hold multiple windows | * '''region''' - your terminal screen can be divided in regions where each can hold multiple windows | ||
== Useful key bindings == | == Useful commands and key bindings == | ||
<source> | |||
$ screen -ls #list detached sessions | |||
$ screen -r #re attach | |||
</source> | |||
{| | |||
;Quick start | |||
*<code>C^a c</code> create new prompt | |||
*<code>C^a tab</code> move to a next window | |||
*<code>C^a |</code> split vertically | |||
*<code>C^a S</code> split horizontly | |||
*<code>C^a \</code> kill all windows, terminate any ssh sessions and exit GNU Screen program | |||
;Key bindings | |||
{| | |||
! Key | ! Key | ||
! Action | ! Action | ||
! Notes | ! Notes | ||
|- | |- | ||
| Ctrl+a c | | <code>Ctrl+a c</code> | ||
| new window | | new window | ||
| | | | ||
|- | |- | ||
| Ctrl+a n | | <code>Ctrl+a n</code> | ||
| next window | | next window | ||
| I bind F12 to this | | I bind F12 to this | ||
|- | |- | ||
| Ctrl+a p | | <code>Ctrl+a p</code> | ||
| previous window | | previous window | ||
| I bind F11 to this | | I bind F11 to this | ||
|- | |- | ||
| Ctrl+a " | | <code>Ctrl+a "</code> | ||
| select window from list | | select window from list | ||
| I have window list in the status line | | I have window list in the status line | ||
|- | |- | ||
| Ctrl+a | | <code>Ctrl+a</code> | ||
| previous window viewed | | previous window viewed | ||
| | | | ||
Line 44: | Line 233: | ||
| | | | ||
|- | |- | ||
| Ctrl+a S | | <code>Ctrl+a S</code> | ||
| split terminal horizontally into regions | | split terminal horizontally into regions | ||
| Ctrl+a c to create new window there | | <code>Ctrl+a c</code> to create new window there | ||
|- | |- | ||
| Ctrl+a | | | <code>Ctrl+a <nowiki>|</nowiki></code> | ||
| split terminal vertically into regions | | split terminal vertically into regions | ||
| Requires screen >= 4.1 | | Requires screen >= 4.1 | ||
|- | |- | ||
| Ctrl+a :resize | | <code>Ctrl+a :resize</code> | ||
| resize region | | resize region | ||
| | | | ||
|- | |- | ||
| Ctrl+a :fit | | <code>Ctrl+a :fit</code> | ||
| fit screen size to new terminal size | | fit screen size to new terminal size | ||
| Ctrl+a F is the same. Do after resizing xterm | | <code>Ctrl+a F</code> is the same. Do after resizing xterm | ||
|- | |- | ||
| Ctrl+a :remove | | <code>Ctrl+a :remove</code> | ||
| remove region | | remove region | ||
| Ctrl+a X is the same | | <code>Ctrl+a X</code> is the same | ||
|- | |- | ||
| Ctrl+a tab | | <code>Ctrl+a tab</code> | ||
| Move to next region | | Move to next region | ||
| | | | ||
Line 72: | Line 261: | ||
| | | | ||
|- | |- | ||
| Ctrl+a d | | <code>Ctrl+a d</code> | ||
| detach screen from terminal | | detach screen from terminal | ||
| Start screen with -r option to reattach | | Start screen with -r option to reattach | ||
|- | |- | ||
| Ctrl+a A | | <code>Ctrl+a A</code> | ||
| set window title | | set window title | ||
| | | | ||
|- | |- | ||
| Ctrl+a x | | <code>Ctrl+a x</code> | ||
| lock session | | lock session | ||
| Enter user password to unlock | | Enter user password to unlock | ||
|- | |- | ||
| Ctrl+a [ | | <code>Ctrl+a [</code> | ||
| enter scrollback/copy mode | | enter scrollback/copy mode | ||
| Enter to start and end copy region. Ctrl+a ] to leave this mode | | Enter to start and end copy region. <code>Ctrl+a ]</code> to leave this mode | ||
|- | |- | ||
| Ctrl+a ] | | <code>Ctrl+a ]</code> | ||
| paste buffer | | paste buffer | ||
| Supports pasting between windows | | Supports pasting between windows | ||
|- | |- | ||
| Ctrl+a > | | <code>Ctrl+a ></code> | ||
| write paste buffer to file | | write paste buffer to file | ||
| useful for copying between screens | | useful for copying between screens | ||
|- | |- | ||
| Ctrl+a < | | <code>Ctrl+a <</code> | ||
| read paste buffer from file | | read paste buffer from file | ||
| useful for pasting between screens | | useful for pasting between screens | ||
Line 104: | Line 293: | ||
| | | | ||
|- | |- | ||
| Ctrl+a ? | | <code>Ctrl+a ?</code> | ||
| show key bindings/command names | | show key bindings/command names | ||
| Note unbound commands only in man page | | Note unbound commands only in man page | ||
|- | |- | ||
| Ctrl+a : | | <code>Ctrl+a :</code> | ||
| goto screen command prompt | | goto screen command prompt | ||
| up shows last command entered | | up shows last command entered | ||
Line 114: | Line 303: | ||
== Scroll back - a copy mode == | == Scroll back - a copy mode == | ||
In GNU Screen press <code>Ctrl + a + [</code> or <code>C^a C^ESC</code> to enter Copy Mode, then scroll up/down using keys j or k. Below are some other navigation keys: | In GNU Screen press <code>Ctrl + a + [</code> or <code>C^a C^ESC</code> to enter Copy Mode, then scroll PgUp/PgDown or up/down using keys j or k. Use Enter key to start and end selection coping to registry/buffer. Below are some other navigation keys: | ||
h - Move the cursor left by one character | h - Move the cursor left by one character | ||
Line 128: | Line 317: | ||
C-d - Scrolls a half page down. | C-d - Scrolls a half page down. | ||
C-f - Scrolls the full page down. | C-f - Scrolls the full page down. | ||
PgUp / PgDown - Scrolls a page up/down | |||
Define scrollback buffer size start screen with the following key (5000 lines in this example): | Define scrollback buffer size start screen with the following key (5000 lines in this example): | ||
Line 140: | Line 330: | ||
Example of a config file: | Example of a config file: | ||
<source> | |||
~$ cat screen-4regions.screen | |||
layout FourScreens #it's a new feature, makes screen aware of regions layout | |||
# Region 0 | |||
screen -t mail1-queue #creates new terminal/prompt | |||
select 0 #select window0 | |||
stuff "echo Window0^M" #echo a string between quotes, ^M translates to EOL means enter-return key | |||
stuff "sshpass -p 'password' ssh -o PubkeyAuthentication=no root@example.com^M" #ssh interactively | |||
split #split horizontally | |||
split -v #split vertically | |||
# Region 1 | |||
select 1 | |||
focus #get focus on a selected region | |||
screen -t mail2-queue sshpass -p 'password' ssh -o PubkeyAuthentication=no root@example.com | |||
#create a new terminal/prompt '''-t mail2-queue''' in the focus window and | |||
#executes the command | |||
stuff "echo Window1^M" | |||
# Region 2 | |||
select 2 | |||
focus | |||
screen -t mail1 | |||
stuff "echo Window2^M" | |||
split -v | |||
# Region 3 | |||
select 3 | |||
focus | |||
screen -t mail2 | |||
stuff "echo Window3^M" | |||
altscreen on | |||
term screen-256color | |||
bind ',' prev | |||
bind '.' next | |||
# | |||
#change the hardstatus settings to give an window list at the bottom of the | |||
#screen, with the time and date and with the current window highlighted | |||
hardstatus alwayslastline | |||
#hardstatus string '%{= kG}%-Lw%{= kW}%50> %n%f* %t%{= kG}%+Lw%< %{= kG}%-=%c:%s%{-}' | |||
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]' | |||
#layout save default #makes regions saved when you re-attach a session | |||
</source> | |||
= 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 | |||
Issues: | |||
* [https://www.claudiokuenzler.com/blog/862/terminator-terminal-inserting-each-character-twice-double-broadcast-multiple-windows broadcast group inserting chars twice] | |||
= [[ Windows ComEmu ]] = | |||
= References = | = References = | ||
*[https://www.gnu.org/software/screen/manual/screen.html User Guide] HTML one page | *[https://www.gnu.org/software/screen/manual/screen.html User Guide] HTML one page | ||
*[https://tmux.github.io/ Tmux] Official website | *[https://tmux.github.io/ Tmux] Official website | ||
*[https://gist.github.com/andreyvit/2921703 tmux cheat sheet] TOP CLASS! | |||
*[https://linux.die.net/man/1/terminator Terminator] Key bindings man page |
Latest revision as of 18:03, 21 December 2020
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(aka tabs) and 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
Indicator, bottom left conrner
[0] 0:bash- 1:bash* # currently looking at 'tab 1' of tmux window(tab) '0'.
Install Tmux
- Install - Linux via package manager
sudo apt-get install tmux
- Install - Windows
- Install Git for Windows SDK
run /bin/pacman -S tmux
- Quick Start
/usr/bin/tmux
- Auto completion [1]
wget -q https://github.com/imomaliev/tmux-bash-completion/raw/master/completions/tmux -O ~/.bash_completion_tmux # add to ~/.bashrc echo "source ~/.bash_completion_tmux" >> ~/.bashrc
- References
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
- Windows(aka tabs)
C^b c
create new window(aka tab), creates a full size window on top of your panesC^n c
switch to next window(aka tab)C^p c
switch to previous window(aka tab)C^l c
switch to last window(aka tab)C^b ,
rename current windowC^b d
detach current sessionC^b D
gives you a choice what session you wish to detach
- Pane
C^b "
split a pane horizontallyC^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 swap
- 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
Commands
C^b, :setw synchronize-panes on C^b, :setw synchronize-panes off
Tmux Plugin Manager
Clone TPM
$ git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
Put this at the bottom of ~/.tmux.conf
($XDG_CONFIG_HOME/tmux/tmux.conf
works too):
# List of plugins set -g @plugin 'tmux-plugins/tpm' set -g @plugin 'tmux-plugins/tmux-resurrect' # set -g @plugin 'tmux-plugins/tmux-sensible' # Other examples: # set -g @plugin 'github_username/plugin_name' # set -g @plugin 'git@github.com/user/plugin' # set -g @plugin 'git@bitbucket.com/user/plugin' # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) run -b '~/.tmux/plugins/tpm/tpm'
Reload TMUX environment so TPM is sourced:
# type this in Tmux terminal if tmux is already running $ tmux source ~/.tmux.conf
That's it!
- Installing plugins
- Add new plugin to
~/.tmux.conf
withset -g @plugin '...'
- Press prefix + I (capital i, as in Install) to fetch the plugin.
You're good to go! The plugin was cloned to ~/.tmux/plugins/
dir and sourced.
- Uninstalling plugins
- Remove (or comment out) plugin from the list.
- Press
prefix + alt + u
(lowercase u as in uninstall) to remove the plugin.
All the plugins are installed to ~/.tmux/plugins/ so alternatively you can find plugin directory there and remove it.
Tmux Resurrect
Restore tmux environment after system restart.
- Installation with Tmux Plugin Manager (recommended)
Add plugin to the list of TPM plugins in .tmux.conf
:
set -g @plugin 'tmux-plugins/tmux-resurrect'
Hit prefix + I
to fetch the plugin and source it. You should now be able to use the plugin, no restart required.
Key bindings
prefix + Ctrl-s
- saveprefix + Ctrl-r
- restore
Tmuxinator
Create and manage tmux sessions easily.
Screen
sudo apt-get install screen
Key terms
- window - it's a separate window that you can switch between
- region - your terminal screen can be divided in regions where each can hold multiple windows
Useful commands and key bindings
$ screen -ls #list detached sessions $ screen -r #re attach
- Quick start
C^a c
create new promptC^a tab
move to a next windowC^a |
split verticallyC^a S
split horizontlyC^a \
kill all windows, terminate any ssh sessions and exit GNU Screen program
- Key bindings
Key | Action | Notes |
---|---|---|
Ctrl+a c
|
new window | |
Ctrl+a n
|
next window | I bind F12 to this |
Ctrl+a p
|
previous window | I bind F11 to this |
Ctrl+a "
|
select window from list | I have window list in the status line |
Ctrl+a
|
previous window viewed | |
Ctrl+a S
|
split terminal horizontally into regions | Ctrl+a c to create new window there
|
Ctrl+a |
|
split terminal vertically into regions | Requires screen >= 4.1 |
Ctrl+a :resize
|
resize region | |
Ctrl+a :fit
|
fit screen size to new terminal size | Ctrl+a F is the same. Do after resizing xterm
|
Ctrl+a :remove
|
remove region | Ctrl+a X is the same
|
Ctrl+a tab
|
Move to next region | |
Ctrl+a d
|
detach screen from terminal | Start screen with -r option to reattach |
Ctrl+a A
|
set window title | |
Ctrl+a x
|
lock session | Enter user password to unlock |
Ctrl+a [
|
enter scrollback/copy mode | Enter to start and end copy region. Ctrl+a ] to leave this mode
|
Ctrl+a ]
|
paste buffer | Supports pasting between windows |
Ctrl+a >
|
write paste buffer to file | useful for copying between screens |
Ctrl+a <
|
read paste buffer from file | useful for pasting between screens |
Ctrl+a ?
|
show key bindings/command names | Note unbound commands only in man page |
Ctrl+a :
|
goto screen command prompt | up shows last command entered |
Scroll back - a copy mode
In GNU Screen press Ctrl + a + [
or C^a C^ESC
to enter Copy Mode, then scroll PgUp/PgDown or up/down using keys j or k. Use Enter key to start and end selection coping to registry/buffer. Below are some other navigation keys:
h - Move the cursor left by one character j - Move the cursor down by one line k - Move the cursor up by one line l - Move the cursor right by one character 0 - Move to the beginning of the current line $ - Move to the end of the current line. G - Moves to the specified line (defaults to the end of the buffer). C-u - Scrolls a half page up. C-b - Scrolls a full page up. C-d - Scrolls a half page down. C-f - Scrolls the full page down. PgUp / PgDown - Scrolls a page up/down
Define scrollback buffer size start screen with the following key (5000 lines in this example):
screen -h 5000
Update: You can use activate copy mode of GNU Screen also by Ctrl + Esc that might be more useful than Ctrl + a + [ shortcut (thanks to Yu-Jie Lin for this tip).
Custom configuration
By default the config is kept in ~/.screenrc
file but using -c option we can pass a custom config
~$ screen -c screen-4regions.screen
Example of a config file:
~$ cat screen-4regions.screen layout FourScreens #it's a new feature, makes screen aware of regions layout # Region 0 screen -t mail1-queue #creates new terminal/prompt select 0 #select window0 stuff "echo Window0^M" #echo a string between quotes, ^M translates to EOL means enter-return key stuff "sshpass -p 'password' ssh -o PubkeyAuthentication=no root@example.com^M" #ssh interactively split #split horizontally split -v #split vertically # Region 1 select 1 focus #get focus on a selected region screen -t mail2-queue sshpass -p 'password' ssh -o PubkeyAuthentication=no root@example.com #create a new terminal/prompt '''-t mail2-queue''' in the focus window and #executes the command stuff "echo Window1^M" # Region 2 select 2 focus screen -t mail1 stuff "echo Window2^M" split -v # Region 3 select 3 focus screen -t mail2 stuff "echo Window3^M" altscreen on term screen-256color bind ',' prev bind '.' next # #change the hardstatus settings to give an window list at the bottom of the #screen, with the time and date and with the current window highlighted hardstatus alwayslastline #hardstatus string '%{= kG}%-Lw%{= kW}%50> %n%f* %t%{= kG}%+Lw%< %{= kG}%-=%c:%s%{-}' hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]' #layout save default #makes regions saved when you re-attach a session
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
Issues:
Windows ComEmu
References
- User Guide HTML one page
- Tmux Official website
- tmux cheat sheet TOP CLASS!
- Terminator Key bindings man page