Report issue Add example

bind

Display or set keyboard key bindings and their related functions.

Description

The bind command is used to display and set keyboard sequence bindings for the command line. Using this command can improve operational efficiency in the command line. You can use the bind command to find out which key combinations are associated with which functions, or you can specify your own key combinations.

Syntax

bind [options]

Options

-d: Display the content of the key configuration.
-f <key_config_file>: Load the specified key configuration file.
-l: List all functions.
-m <key_map>: Specify a key map.
-q <function>: Display the keys for a specified function.
-v: List current key bindings and their functions.

Examples

bind -x '"\C-l":ls -l'    # Pressing CTRL+L directly lists the directory

The keyseq can be obtained using the showkey -a command:

showkey -a

Press any keys - Ctrl-D will terminate this program

^[[A     27 0033 0x1b  Up
         91 0133 0x5b
         65 0101 0x41
^[[B     27 0033 0x1b  Down
         91 0133 0x5b
         66 0102 0x42
^[[D     27 0033 0x1b  Left
         91 0133 0x5b
         68 0104 0x44
^[[C     27 0033 0x1b  Right
         91 0133 0x5b
         67 0103 0x43
         32 0040 0x20
^M       13 0015 0x0d  Carriage Return
^C        3 0003 0x03  Ctrl-C
^D        4 0004 0x04  Ctrl-D (Exit)