====== bind ======
===== Default Keybindings =====
None.
===== Syntax =====
* ''**bind** [-c //class//] //key// [//command// [//args//]]''
===== Description =====
Bind a command to a key. By default, most of the commands provided by
screen are bound to one or more keys as indicated in the [[man:Default Key
Bindings]] section, e.g. the command to create a new window is bound to
"''C-c''" and "''c''". The ''bind'' command can be used to redefine the
key bindings and to define new bindings. The //key// argument is either a
single character, a two-character sequence of the form "''^x''" (meaning
"''C-x''"), a backslash followed by an octal number (specifying the ASCII
code of the character), or a backslash followed by a second character,
such as "''\^''" or "''\\''". The argument can also be quoted, if you
like. If no further argument is given, any previously established binding
for this key is removed. The //command// argument can be any ''screen''
command.
If a command class is specified via the ''-c'' option, the key is bound
for the specified class. Use the ''[[commands:command]]'' command to
activate a class. Command classes can be used to create multiple command
keys or multi-character bindings.
===== Examples =====
bind ’ ’ windows
bind ^k
bind k
bind K kill
bind ^f screen telnet foobar
bind \033 screen -ln -t root -h 1000 9 su
binds the space key to the command that displays a list of windows (so
that the command usually invoked by "''[[commands:windows|C-a C-w]]''"
would also be available as "''C-a space''"). The next three lines remove
the default kill binding from "''C-a C-k''" and "''C-a k''". "''C-a K''"
is then bound to the ''[[commands:kill]]'' command. Then it binds "''C-a
C-f''" to the command "create a window with a TELNET connection to foobar"
(c.f. [[man:Window Types]]), and binds "escape" to a command that creates
a non-login window with a.k.a. "root" in slot #9, with a superuser shell
and a scrollback buffer of 1000 lines (c.f. ''[[commands:screen]]'').
bind -c demo1 0 select 10
bind -c demo1 1 select 11
bind -c demo1 2 select 12
bindkey "^B" command -c demo1
makes "''C-b 0''" select window 10, "''C-b 1''" window 11, etc.
bind -c demo2 0 select 10
bind -c demo2 1 select 11
bind -c demo2 2 select 12
bind - command -c demo2
makes "''C-a - 0''" select window 10, "''C-a - 1''" window 11, etc.
===== See Also =====
* [[:interface]]