📄 readline.html
字号:
</P><P><DL COMPACT><DT><CODE>$if</CODE><DD>The <CODE>$if</CODE> 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.<P><DL COMPACT><DT><CODE>mode</CODE><DD>The <CODE>mode=</CODE> form of the <CODE>$if</CODE> directive is used to testwhether Readline is in <CODE>emacs</CODE> or <CODE>vi</CODE> mode.This may be used in conjunctionwith the <SAMP>`set keymap'</SAMP> command, for instance, to set bindings inthe <CODE>emacs-standard</CODE> and <CODE>emacs-ctlx</CODE> keymaps only ifReadline is starting out in <CODE>emacs</CODE> mode.<P><DT><CODE>term</CODE><DD>The <CODE>term=</CODE> 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>`='</SAMP> is tested against both the full name of the terminal andthe portion of the terminal name before the first <SAMP>`-'</SAMP>. Thisallows <CODE>sun</CODE> to match both <CODE>sun</CODE> and <CODE>sun-cmd</CODE>,for instance.<P><DT><CODE>application</CODE><DD>The <VAR>application</VAR> construct is used to includeapplication-specific settings. Each program using the Readlinelibrary sets the <VAR>application name</VAR>, 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:<TABLE><tr><td> </td><td class=example><pre>$if Bash# Quote the current or previous word"\C-xq": "\eb\"\ef\""$endif</pre></td></tr></table></DL><P><DT><CODE>$endif</CODE><DD>This command, as seen in the previous example, terminates an<CODE>$if</CODE> command.<P><DT><CODE>$else</CODE><DD>Commands in this branch of the <CODE>$if</CODE> directive are executed ifthe test fails.<P><DT><CODE>$include</CODE><DD>This directive takes a single filename as an argument and reads commandsand bindings from that file.For example, the following directive reads from <TT>`/etc/inputrc'</TT>:<TABLE><tr><td> </td><td class=example><pre>$include /etc/inputrc</pre></td></tr></table></DL><P><A NAME="Sample Init File"></A><HR SIZE="6"><A NAME="SEC12"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC11"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC13"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC13"> << </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC9"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC13"> >> </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC52">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_About"> ? </A>]</TD></TR></TABLE><H3> 1.3.3 Sample Init File </H3><!--docid::SEC12::--><P>Here is an example of an <VAR>inputrc</VAR> file. This illustrates keybinding, variable assignment, and conditional syntax.</P><P><TABLE><tr><td> </td><td class=example><pre># 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</pre></td></tr></table></P><P><A NAME="Bindable Readline Commands"></A><HR SIZE="6"><A NAME="SEC13"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC12"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC14"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC22"> << </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC1"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC22"> >> </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC52">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_About"> ? </A>]</TD></TR></TABLE><H2> 1.4 Bindable Readline Commands </H2><!--docid::SEC13::--><P><BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC14">1.4.1 Commands For Moving</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Moving about the line.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC15">1.4.2 Commands For Manipulating The History</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Getting at previous lines.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC16">1.4.3 Commands For Changing Text</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Commands for changing text.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC17">1.4.4 Killing And Yanking</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Commands for killing and yanking.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC18">1.4.5 Specifying Numeric Arguments</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Specifying numeric arguments, repeat counts.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC19">1.4.6 Letting Readline Type For You</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Getting Readline to do the typing for you.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC20">1.4.7 Keyboard Macros</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Saving and re-executing typed characters</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="readline.html#SEC21">1.4.8 Some Miscellaneous Commands</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Other miscellaneous commands.</TD></TR></TABLE></BLOCKQUOTE><P>This section describes Readline commands that may be bound to keysequences.Command names without an accompanying key sequence are unbound by default.</P><P>In the following descriptions, <EM>point</EM> refers to the current cursorposition, and <EM>mark</EM> refers to a cursor position saved by the<CODE>set-mark</CODE> command.The text between the point and mark is referred to as the <EM>region</EM>.</P><P><A NAME="Commands For Moving"></A><HR SIZE="6"><A NAME="SEC14"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC13"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC15"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC22"> << </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC13"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC22"> >> </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC52">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_About"> ? </A>]</TD></TR></TABLE><H3> 1.4.1 Commands For Moving </H3><!--docid::SEC14::--><DL COMPACT><A NAME="IDX27"></A><DT><CODE>beginning-of-line (C-a)</CODE><DD><A NAME="IDX28"></A>Move to the start of the current line.<P><A NAME="IDX29"></A><DT><CODE>end-of-line (C-e)</CODE><DD><A NAME="IDX30"></A>Move to the end of the line.<P><A NAME="IDX31"></A><DT><CODE>forward-char (C-f)</CODE><DD><A NAME="IDX32"></A>Move forward a character.<P><A NAME="IDX33"></A><DT><CODE>backward-char (C-b)</CODE><DD><A NAME="IDX34"></A>Move back a character.<P><A NAME="IDX35"></A><DT><CODE>forward-word (M-f)</CODE><DD><A NAME="IDX36"></A>Move forward to the end of the next word. Words are composed ofletters and digits.<P><A NAME="IDX37"></A><DT><CODE>backward-word (M-b)</CODE><DD><A NAME="IDX38"></A>Move back to the start of the current or previous word. Words arecomposed of letters and digits.<P><A NAME="IDX39"></A><DT><CODE>clear-screen (C-l)</CODE><DD><A NAME="IDX40"></A>Clear the screen and redraw the current line,leaving the current line at the top of the screen.<P><A NAME="IDX41"></A><DT><CODE>redraw-current-line ()</CODE><DD><A NAME="IDX42"></A>Refresh the current line. By default, this is unbound.<P></DL><P><A NAME="Commands For History"></A><HR SIZE="6"><A NAME="SEC15"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC14"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC16"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC16"> << </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC13"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC22"> >> </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC52">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="readline.html#SEC_About"> ? </A>]</TD></TR></TABLE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -