Next: , Previous: , Up: Top   [Contents][Index]


21 String Escapes

Screen provides an escape mechanism to insert information like the current time into messages or file names. The escape character is % with one exception: inside of a window’s hardstatus ^% (^E) is used instead.

Here is the full list of supported escapes:

%

the escape character itself

a

either am or pm

A

either AM or PM

c

current time HH:MM in 24h format

C

current time HH:MM in 12h format

d

day number

D

weekday name

E

sets %? to true if the escape character has been pressed.

f

flags of the window. See Windows, for meanings of the various flags.

F

sets %? to true if the window has the focus

h

hardstatus of the window

H

hostname of the system

O

count of screen windows. Prefix with '-' to limit to current window group.

l

current load of the system

m

month number

M

month name

n

window number

P

sets %? to true if the current region is in copy/paste mode

S

session name

t

window title

u

all other users on this window

w

all window numbers and names. With - qualifier: up to the current window; with + qualifier: starting with the window after the current one.

W

all window numbers and names except the current one

y

last two digits of the year number

Y

full year number

?

the part to the next %? is displayed only if a % escape inside the part expands to a non-empty string

:

else part of %?

=

pad the string to the display’s width (like TeX’s hfill). If a number is specified, pad to the percentage of the window’s width. A 0 qualifier tells screen to treat the number as absolute position. You can specify to pad relative to the last absolute pad position by adding a + qualifier or to pad relative to the right margin by using -. The padding truncates the string if the specified position lies before the current position. Add the L qualifier to change this.

<

same as %= but just do truncation, do not fill with spaces

>

mark the current text position for the next truncation. When screen needs to do truncation, it tries to do it in a way that the marked position gets moved to the specified percentage of the output area. (The area starts from the last absolute pad position and ends with the position specified by the truncation operator.) The L qualifier tells screen to mark the truncated parts with ‘...’.

{

attribute/color modifier string terminated by the next }

`

Substitute with the output of a ‘backtick’ command. The length qualifier is misused to identify one of the commands. See Backtick.

The c and C escape may be qualified with a 0 to make screen use zero instead of space as fill character. The n and = escapes understand a length qualifier (e.g. %3n), D and M can be prefixed with L to generate long names, w and W also show the window flags if L is given.

An attribute/color modifier is used to change the attributes or the color settings. Its format is ‘[attribute modifier] [color description]’. The attribute modifier must be prefixed by a change type indicator if it can be confused with a color description. The following change types are known:

+

add the specified set to the current attributes

-

remove the set from the current attributes

!

invert the set in the current attributes

=

change the current attributes to the specified set

The attribute set can either be specified as a hexadecimal number or a combination of the following letters:

d

dim

u

underline

b

bold

r

reverse

s

standout

B

blinking

The old format of specifying colors by letters (k,r,g,y,b,m,c,w) is now deprecated. Colors are coded as 0-7 for basic ANSI, 0-255 for 256 color mode, or for truecolor, either a hexadecimal code starting with x, or HTML notation as either 3 or 6 hexadecimal digits. Foreground and background are specified by putting a semicolon between them. Ex: #FFF;#000 or i7;0 is white on a black background.

The following numbers are for basic ANSI:

0

black

1

red

2

green

3

yellow

4

blue

5

magenta

6

cyan

7

white

You can also use the pseudo-color ’i’ to set just the brightness and leave the color unchanged. As a special case, ‘%{-}’ restores the attributes and colors that were set before the last change was made (i.e. pops one level of the color-change stack).

Examples:

i2

set color to bright green

+b r

use bold red

#F00;FFA

write in bright red color on a pale yellow background

%-Lw%{#AAA;#006}%50>%n%f* %t%{-}%+Lw%<

The available windows centered at the current window and truncated to the available width. The current window is displayed white on blue. This can be used with ‘hardstatus alwayslastline’.

%?%F%{;2}%?%3n %t%? [%h]%?

The window number and title and the window’s hardstatus, if one is set. Also use a red background if this is the active focus. Useful for ‘caption string’.


Next: Environment Variables, Previous: Miscellaneous commands, Up: Top   [Contents][Index]