236-238.html

来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 147 行

HTML
147
字号
<HTML>

<HEAD>

<TITLE>Linux Unleashed, Third Edition:pdksh</TITLE>

<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=0672313723//-->

<!--TITLE=Linux Unleashed, Third Edition//-->

<!--AUTHOR=Tim Parker//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Sams//-->

<!--CHAPTER=12//-->

<!--PAGES=236-238//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="234-236.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="239-242.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H3><A NAME="Heading12"></A><FONT COLOR="#000077">Key Bindings</FONT></H3>

<P>One useful feature that <TT>pdksh</TT> supports, which is lacking in the Bourne Again Shell, is <I>key bindings</I>. This feature enables you to change the behavior of key combinations for the purpose of command-line editing.</P>

<P>If, for example, you do not like the fact that you have to use the <TT>emacs</TT> key sequence Ctrl&#43;P to move up in the history buffer, you can change the key sequence for that command to something else. The syntax for doing the key binding is the following:</P>

<!-- CODE SNIP //-->

<PRE>

bind &lt;key sequence&gt; &lt;command&gt;

</PRE>

<!-- END CODE SNIP //-->

<P>This feature effectively enables you to customize <TT>pdksh</TT> to have the exact feel that you want. One of the most commonly used key bindings is to bind the up, down, left, and right arrows to be used as they are in <TT>bash</TT> (for scrolling up and down the history list, and for moving left and right along the command line). This binding is typically found in your <TT>.kshrc</TT> file, which is the startup file for the shell (it is read whenever the shell starts).</P>

<P>The <TT>bind</TT> commands that are needed to create these bindings are as follows:</P>

<!-- CODE SNIP //-->

<PRE>

bind &#145;^[[&#146;=prefix-2

bind &#145;^XA&#146;=up-history

bind &#147;^XB&#146;=down-history

bind &#145;^XC&#146;=forward-char

bind &#145;^XD&#146;=backward-char

</PRE>

<!-- END CODE SNIP //-->

<P>Table 12.1 gives some of the most useful editing commands that you can use for binding keys, along with the default binding and a description of each. You can get a listing of all of the editing commands that <TT>pdksh</TT> supports by typing the <TT>bind</TT> command without any arguments.</P>

<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 12.1.</B> Useful key bindings for <TT>pdksh</TT>.

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TH WIDTH="45%" ALIGN="LEFT">Keystroke

<TH WIDTH="55%" ALIGN="LEFT">Meaning

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TD VALIGN="TOP"><TT>abort (^G)</TT>

<TD>Used to abort another editing command. It is most commonly used to stop a history list search.

<TR>

<TD VALIGN="TOP"><TT>backward-char (^B)</TT>

<TD>Moves the cursor backward one character. This command is often bound to the left arrow key.

<TR>

<TD VALIGN="TOP"><TT>backward-word (^[b)</TT>

<TD>Moves the cursor backward to the beginning of a word.

<TR>

<TD VALIGN="TOP"><TT>beginning-of-line (^A)</TT>

<TD>Moves the cursor to the beginning of the command line.

<TR>

<TD VALIGN="TOP"><TT>complete (^[^[)</TT>

<TD>Tells pdksh to try to complete the current command.

<TR>

<TD VALIGN="TOP"><TT>copy-last-arg (^[_)</TT>

<TD>Causes the last word of the previous command to be inserted at the cursor position.

<TR>

<TD VALIGN="TOP"><TT>delete-char-backward (ERASE)</TT>

<TD>Deletes the character that is to the left of thecursor.

<TR>

<TD><TT>delete-char-forward</TT>

<TD>Deletes the character to the right of the cursor.

<TR>

<TD VALIGN="TOP"><TT>delete-word-backward (^[ERASE)</TT>

<TD>Deletes the characters to the left of the cursor back to the first white space character that is encountered.

<TR>

<TD VALIGN="TOP"><TT>delete-word-forward (^[(d)</TT>

<TD>Deletes the characters to the right of the cursor up to the first character that occurs after a white space character.

<TR>

<TD VALIGN="TOP"><TT>down-history (^N)</TT>

<TD>Moves down one line in the history list. This command is often bound to the down-arrow key.

<TR>

<TD><TT>end-of-line (^E)</TT>

<TD>Moves the cursor to the end of the current line.

<TR>

<TD VALIGN="TOP"><TT>forward-char (^F)</TT>

<TD>Moves the cursor forward one character. This command is often bound to the right-arrow key.

<TR>

<TD><TT>forward-word (^[F)</TT>

<TD>Moves the cursor forward to the end of a word.

<TR>

<TD><TT>kill-line (KILL)</TT>

<TD>Deletes the current line.

<TR>

<TD VALIGN="TOP"><TT>kill-to-eol (^K)</TT>

<TD>deletes all of the characters to the right of the cursor on the current line.

<TR>

<TD VALIGN="TOP"><TT>list (^[?)</TT>

<TD>Causes pdksh to list all of the possible command names or filenames that can complete the word in which the cursor is currently contained.

<TR>

<TD VALIGN="TOP"><TT>search-history (^R)</TT>

<TD>Searches the history list backward for the first command that contains the inputted char-acters.

<TR>

<TD VALIGN="TOP"><TT>transpose-chars (^T)</TT>

<TD>Exchanges the two characters on either side of the cursor. If the cursor is at the end of the command line it switches the last two characters on the line.

<TR>

<TD VALIGN="TOP"><TT>up-history (^P)</TT>

<TD>Moves up one command in the history list. This command is often bound to the up-arrow key.

<TR>

<TD COLSPAN="2"><HR>

</TABLE>

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="234-236.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="239-242.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?