:
, and actually start typing Ctrl-a n, you'll switch to the next window .^
. For example : Ctrl-a becomes ^A
^x
(Ctrl-x)\^
or \\
^Aa
, but ``
is recommended by one of the authors.
# free the escape sequence ('Ctrl-a') by setting it to a suggested default I never use escape `` # set my own sequence bindkey "²" command
The environment is inherited by all subsequently forked shells.
So you'd better choose variable names that won't collide with other usages. So far, I prefix such variables with gnuScreenDotscreenrc_
.
Hotkey | Usage |
---|---|
Ctrl-a, A | Annotate : set the Screen window name |
Ctrl-a, c | create a new window inside a Screen session |
Ctrl-a, d | detach from the Screen session and all its windows (details) |
Ctrl-a, k | kill : leave the current window (same as exit). NB : when all windows are killed, Screen dies also |
Ctrl-a, M | Toggle Monitoring of activity in the current window |
Ctrl-a, n | Switch to the next window |
Ctrl-a, Q | Maximize current window and leave split screen mode (details) |
Ctrl-a, q | exit "command buffer" |
Ctrl-a, S | split the current window with an horizontal line |
Ctrl-a, X | delete the current region when in split mode |
Ctrl-a, n | select Screen window number n (get Screen window numbers) |
Ctrl-a, " | list windows of current Screen session : number + name + flags |
Ctrl-a, | | split the current window with a vertical line |
Ctrl-a, ESC Ctrl-a, [ |
Enter copy mode allowing to scroll beyond the top of the display output. Exit with ESC or q. (source) |
Ctrl-a, TAB | Switches windows once in split screen mode. |
Ctrl-a, : | Enter console mode. This allows to type commands to alter the current session on-the-fly without editing ~/.screenrc |
In copy mode (Vi-like) | |
|
|
I have some repetitive commands to run manually and I want to make things easier : it would be great if, when I press F3, this is a long string and I'm a lazy guy could be added at the current cursor position in a terminal (Screen window, actually).
To do so :
\015
^M
instead of \015
screen -t window_1 stuff "cd path/to/some/directory; clear^M" screen -t window_2 stuff "cd some/other/directory; clear^M" screen -t window_3 select 0 show window 0 (i.e. the one named window_1)
Copy mode - Column 71 Line 25(+3000) (80,25)Here, scrollback is set to 3000 lines.
defscrollback 10000
Altering Screen window settings can be done by sending the appropriate ANSI codes with the right value. For instance, it is fairly easy to set the Screen window title. Similar changes can be made with the font + background colors.
ESC k Title Definition String ESC P (A) Device Control String Outputs a string directly to the host terminal without interpretation.
$STY
has a value in Screen, and is empty otherwise.
This is $STY
, not $TTY
!
windowTitle=$(screen -Q title); echo "$windowTitle"
There's a little glitch with the screen -Q command : it displays its result in the window "notification area" (bottom line) for a few seconds, which freezes the shell during that time. This delay is controlled by the msgwait directive, which can be reset by adding to ~/.screenrc :
msgwait 0
There is a screen on: PID.sessionName (Attached) 1 Socket in /var/run/screen/userName.So, running screen -d sessionName should do the trick and let the session be resumed with screen -r sessionName. However, sometimes this doesn't work as expected (for unknown reasons so far), since after trying to detach the session, screen -ls still displays it as attached.
screen -d -r sessionName
This procedure is pointless for small chunks of text that fit the display : just select/copy text with the mouse as usual
Copied 42 characters into buffer
)
+ autodetach on startup_message off hardstatus alwayslastline "%{kb}%{c}[%{w}%D %d/%m/%Y %c:%s%{c}] %{w}%-w%{rk}%n %t%{wb}%+w %=%{c}[%{W}%H %l%{c}]" bindkey -k k6 prev bindkey -k k7 nextThis binds F6 to the previous window, and F7 to the next one. You _may_ also bind a function to a key in Bash.
Flag | Usage |
---|---|
screen screen -S sessionName |
start a new anonymous / named Screen session |
-c configFile | override default configuration file ($HOME/.screenrc) with configFile
To ignore the default configuration file : screen -c /dev/null
|
-d | detach a Screen from outside the session. This is useful when the SSH session was killed by a network problem (details).
It is also possible to detach from inside the session.
|
-ls -list | show all available Screen sessions and their PID |
-r -r PID -r sessionName |
resume the Screen session having the specified PID. The PID can be omitted when there is only 1 Screen session |
-x -x PID |
Attach to a not detached Screen session. (Multi display mode, allowing several users (or several incoming connections) to share a Screen). The PID can be omitted when there is only 1 Screen session. |