📄 rluser.texinfo
字号:
eighth bit set to an @sc{ascii} key sequence by stripping the eighthbit and prefixing an @key{ESC} character, converting them to ameta-prefixed key sequence. The default value is @samp{on}.@item disable-completion@vindex disable-completionIf set to @samp{On}, Readline will inhibit word completion.Completion characters will be inserted into the line as if they hadbeen mapped to @code{self-insert}. The default is @samp{off}.@item editing-mode@vindex editing-modeThe @code{editing-mode} variable controls which default set ofkey bindings is used. By default, Readline starts up in Emacs editingmode, where the keystrokes are most similar to Emacs. This variable can beset to either @samp{emacs} or @samp{vi}.@item enable-keypad@vindex enable-keypadWhen set to @samp{on}, Readline will try to enable the applicationkeypad when it is called. Some systems need this to enable thearrow keys. The default is @samp{off}.@item expand-tilde@vindex expand-tildeIf set to @samp{on}, tilde expansion is performed when Readlineattempts word completion. The default is @samp{off}.@item horizontal-scroll-mode@vindex horizontal-scroll-modeThis variable can be set to either @samp{on} or @samp{off}. Setting itto @samp{on} means that the text of the lines being edited will scrollhorizontally on a single screen line when they are longer than the widthof the screen, instead of wrapping onto a new screen line. By default,this variable is set to @samp{off}.@item input-meta@vindex input-meta@vindex meta-flagIf set to @samp{on}, Readline will enable eight-bit input (itwill not clear the eighth bit in the characters it reads),regardless of what the terminal claims it can support. Thedefault value is @samp{off}. The name @code{meta-flag} is asynonym for this variable.@item isearch-terminators@vindex isearch-terminatorsThe string of characters that should terminate an incremental search withoutsubsequently executing the character as a command (@pxref{Searching}).If this variable has not been given a value, the characters @key{ESC} and@kbd{C-J} will terminate an incremental search.@item keymap@vindex keymapSets Readline's idea of the current keymap for key binding commands.Acceptable @code{keymap} names are@code{emacs},@code{emacs-standard},@code{emacs-meta},@code{emacs-ctlx},@code{vi},@code{vi-move},@code{vi-command}, and@code{vi-insert}.@code{vi} is equivalent to @code{vi-command}; @code{emacs} isequivalent to @code{emacs-standard}. The default value is @code{emacs}.The value of the @code{editing-mode} variable also affects thedefault keymap.@item mark-directoriesIf set to @samp{on}, completed directory names have a slashappended. The default is @samp{on}.@item mark-modified-lines@vindex mark-modified-linesThis variable, when set to @samp{on}, causes Readline to display anasterisk (@samp{*}) at the start of history lines which have been modified.This variable is @samp{off} by default.@item output-meta@vindex output-metaIf set to @samp{on}, Readline will display characters with theeighth bit set directly rather than as a meta-prefixed escapesequence. The default is @samp{off}.@item print-completions-horizontallyIf set to @samp{on}, Readline will display completions with matchessorted horizontally in alphabetical order, rather than down the screen.The default is @samp{off}.@item show-all-if-ambiguous@vindex show-all-if-ambiguousThis alters the default behavior of the completion functions. Ifset to @samp{on}, words which have more than one possible completion cause thematches to be listed immediately instead of ringing the bell.The default value is @samp{off}.@item visible-stats@vindex visible-statsIf set to @samp{on}, a character denoting a file's typeis appended to the filename when listing possiblecompletions. The default is @samp{off}.@end table@item Key BindingsThe syntax for controlling key bindings in the init file issimple. First you need to find the name of the command that youwant to change. The following sections contain tables of the commandname, the default keybinding, if any, and a short description of whatthe command does.Once you know the name of the command, simply place on a linein the init file the name of the keyyou wish to bind the command to, a colon, and then the name of thecommand. The name of the keycan be expressed in different ways, depending on what you find mostcomfortable.In addition to command names, readline allows keys to be boundto a string that is inserted when the key is pressed (a @var{macro}).@ifset BashFeaturesThe @w{@code{bind -p}} command displays Readline function names andbindings in a format that can put directly into an initialization file.@xref{Bash Builtins}.@end ifset@table @asis@item @w{@var{keyname}: @var{function-name} or @var{macro}}@var{keyname} is the name of a key spelled out in English. For example:@exampleControl-u: universal-argumentMeta-Rubout: backward-kill-wordControl-o: "> output"@end exampleIn the above example, @kbd{C-u} is bound to the function@code{universal-argument},@kbd{M-DEL} is bound to the function @code{backward-kill-word}, and@kbd{C-o} is bound to run the macroexpressed on the right hand side (that is, to insert the text@samp{> output} into the line).A number of symbolic character names are recognized whileprocessing this key binding syntax:@var{DEL},@var{ESC},@var{ESCAPE},@var{LFD},@var{NEWLINE},@var{RET},@var{RETURN},@var{RUBOUT},@var{SPACE},@var{SPC},and@var{TAB}.@item @w{"@var{keyseq}": @var{function-name} or @var{macro}}@var{keyseq} differs from @var{keyname} above in that stringsdenoting an entire key sequence can be specified, by placingthe key sequence in double quotes. Some @sc{gnu} Emacs style keyescapes can be used, as in the following example, but thespecial character names are not recognized.@example"\C-u": universal-argument"\C-x\C-r": re-read-init-file"\e[11~": "Function Key 1"@end exampleIn the above example, @kbd{C-u} is again bound to the function@code{universal-argument} (just as it was in the first example),@samp{@kbd{C-x} @kbd{C-r}} is bound to the function @code{re-read-init-file},and @samp{@key{ESC} @key{[} @key{1} @key{1} @key{~}} is bound to insertthe text @samp{Function Key 1}.@end tableThe following @sc{gnu} Emacs style escape sequences are available whenspecifying key sequences:@table @code@item @kbd{\C-}control prefix@item @kbd{\M-}meta prefix@item @kbd{\e}an escape character@item @kbd{\\}backslash@item @kbd{\"}@key{"}, a double quotation mark@item @kbd{\'}@key{'}, a single quote or apostrophe@end tableIn addition to the @sc{gnu} Emacs style escape sequences, a secondset of backslash escapes is available:@table @code@item \aalert (bell)@item \bbackspace@item \ddelete@item \fform feed@item \nnewline@item \rcarriage return@item \thorizontal tab@item \vvertical tab@item \@var{nnn}the character whose @sc{ascii} code is the octal value @var{nnn}(one to three digits)@item \x@var{nnn}the character whose @sc{ascii} code is the hexadecimal value @var{nnn}(one to three digits)@end tableWhen entering the text of a macro, single or double quotes mustbe used to indicate a macro definition.Unquoted text is assumed to be a function name.In the macro body, the backslash escapes described above are expanded.Backslash will quote any other character in the macro text,including @samp{"} and @samp{'}.For example, the following binding will make @samp{@kbd{C-x} \}insert a single @samp{\} into the line:@example"\C-x\\": "\\"@end example@end table@node Conditional Init Constructs@subsection Conditional Init ConstructsReadline implements a facility similar in spirit to the conditionalcompilation features of the C preprocessor which allows keybindings and variable settings to be performed as the resultof tests. There are four parser directives used.@table @code@item $ifThe @code{$if} construct allows bindings to be made based on theediting mode, the terminal being used, or the application usingReadline. The text of the test extends to the end of the line;no characters are required to isolate it.@table @code@item modeThe @code{mode=} form of the @code{$if} directive is used to testwhether Readline is in @code{emacs} or @code{vi} mode.This may be used in conjunctionwith the @samp{set keymap} command, for instance, to set bindings inthe @code{emacs-standard} and @code{emacs-ctlx} keymaps only ifReadline is starting out in @code{emacs} mode.@item termThe @code{term=} form may be used to include terminal-specifickey bindings, perhaps to bind the key sequences output by theterminal's function keys. The word on the right side of the@samp{=} is tested against both the full name of the terminal andthe portion of the terminal name before the first @samp{-}. Thisallows @code{sun} to match both @code{sun} and @code{sun-cmd},for instance.@item applicationThe @var{application} construct is used to includeapplication-specific settings. Each program using the Readlinelibrary sets the @var{application name}, and you can test fora particular value. This could be used to bind key sequences to functions useful fora specific program. For instance, the following command adds akey sequence that quotes the current or previous word in Bash:@example$if Bash# Quote the current or previous word"\C-xq": "\eb\"\ef\""$endif@end example@end table@item $endifThis command, as seen in the previous example, terminates an@code{$if} command.@item $elseCommands in this branch of the @code{$if} directive are executed ifthe test fails.@item $includeThis directive takes a single filename as an argument and reads commandsand bindings from that file.For example, the following directive reads from @file{/etc/inputrc}:@example$include /etc/inputrc@end example@end table@node Sample Init File@subsection Sample Init FileHere is an example of an @var{inputrc} file. This illustrates keybinding, variable assignment, and conditional syntax.@example@page# This file controls the behaviour of line input editing for# programs that use the Gnu Readline library. Existing programs# include FTP, Bash, and Gdb.## You can re-read the inputrc file with C-x C-r.# Lines beginning with '#' are comments.## First, include any systemwide bindings and variable assignments from# /etc/Inputrc$include /etc/Inputrc## Set various bindings for emacs mode.set editing-mode emacs $if mode=emacsMeta-Control-h: backward-kill-word Text after the function name is ignored## Arrow keys in keypad mode##"\M-OD": backward-char#"\M-OC": forward-char#"\M-OA": previous-history#"\M-OB": next-history## Arrow keys in ANSI mode#"\M-[D": backward-char"\M-[C": forward-char"\M-[A": previous-history"\M-[B": next-history## Arrow keys in 8 bit keypad mode##"\M-\C-OD": backward-char#"\M-\C-OC": forward-char#"\M-\C-OA": previous-history#"\M-\C-OB": next-history## Arrow keys in 8 bit ANSI mode##"\M-\C-[D": backward-char#"\M-\C-[C": forward-char#"\M-\C-[A": previous-history#"\M-\C-[B": next-historyC-q: quoted-insert$endif# An old-style binding. This happens to be the default.TAB: complete# Macros that are convenient for shell interaction$if Bash# edit the path"\C-xp": "PATH=$@{PATH@}\e\C-e\C-a\ef\C-f"# prepare to type a quoted word -- insert open and close double quotes# and move to just after the open quote"\C-x\"": "\"\"\C-b"# insert a backslash (testing backslash escapes in sequences and macros)"\C-x\\": "\\"# Quote the current or previous word"\C-xq": "\eb\"\ef\""# Add a binding to refresh the line, which is unbound"\C-xr": redraw-current-line# Edit variable on current line."\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y="$endif# use a visible bell if one is availableset bell-style visible# don't strip characters to 7 bits when readingset input-meta on# allow iso-latin1 characters to be inserted rather than converted to# prefix-meta sequencesset convert-meta off# display characters with the eighth bit set directly rather than# as meta-prefixed charactersset output-meta on# if there are more than 150 possible completions for a word, ask the# user if he wants to see all of themset completion-query-items 150# For FTP$if Ftp"\C-xg": "get \M-?""\C-xt": "put \M-?""\M-.": yank-last-arg$endif@end example@node Bindable Readline Commands@section Bindable Readline Commands@menu* Commands For Moving:: Moving about the line.* Commands For History:: Getting at previous lines.* Commands For Text:: Commands for changing text.* Commands For Killing:: Commands for killing and yanking.* Numeric Arguments:: Specifying numeric arguments, repeat counts.* Commands For Completion:: Getting Readline to do the typing for you.* Keyboard Macros:: Saving and re-executing typed characters* Miscellaneous Commands:: Other miscellaneous commands.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -