rhl11.htm
来自「linux的初学电子书」· HTM 代码 · 共 1,875 行 · 第 1/3 页
HTM
1,875 行
</UL></UL>
<UL>
<UL>
<P>search-history (^R) searches the history list backward for the first command that contains the inputted characters.
<BR>
</UL></UL>
<UL>
<UL>
<P>transpose-chars (^T) 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.
<BR>
</UL></UL>
<UL>
<UL>
<P>up-history (^P) moves up one command in the history list. This command is often bound to the up arrow key.
<BR>
</UL></UL>
<BR>
<A NAME="E68E73"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Customizing Your </B><B>pdksh</B></FONT></CENTER></H3>
<BR>
<P>Many ways of customizing pdksh have been described in this chapter. Until now, though, the changes that you made only affected the current pdksh session. As soon as you quit pdksh, all of the customizations that you made are lost. There is a way of
making the customizations more per-manent.
<BR>
<P>This is done by storing all of your customizations in a pdksh initialization file. Users can put commands into this file that they want to be executed each and every time pdksh is started. Examples of commands that are typically found in this file are
aliases and initializations of variables (such as the prompts).
<BR>
<P>In order to set up your customization file, you must tell pdksh where to look for the initialization file. This is different than with bash. The bash shell automatically knew where to look for its customization file. To tell pdksh where to look for the
customization file, you must create a file in your home directory called .profile. This file is read and all of the commands in the file are executed each time you log into the system.
<BR>
<P>A sample of the commands that you should place in your .profile file are as follows:
<BR>
<PRE>
<FONT COLOR="#000080">export ENV=$HOME/.kshrc
EDITOR=emacs</FONT></PRE>
<P>The first line in the .profile file sets the ENV variable. This is the variable that pdksh looks at to find the initialization file that it should use. If you plan to customize pdksh, you should tell pdksh to look for a file in your home directory. The
filename .kshrc is often used as the pdksh initialization filename, but you can pick another name if you want.
<BR>
<P>If you are not planning to customize pdksh, you can set the ENV variable to be equal to the system default pdksh initialization file. This file is in the /etc directory, and is called ksh.kshrc.
<BR>
<P>The second line in the .profile file sets the EDITOR variable. This is used by the .kshrc initialization file to determine what type of command-line editing commands to use for your session. If you prefer to use vi command-line editing, you can set this
variable to be equal to vi.
<BR>
<P>Listing 11.1 shows most of what is contained in the system's default ksh.kshrc file. If you want to add your own customizations to pdksh, you should copy this file into your home directory and then add the customizations that you want to your own copy
of the file.
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>Instead of copying the file to your home directory, you can create a new file in your home directory that calls the system default file, and then add customizations afterward.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<P>
<FONT COLOR="#000080"><B>Listing 11.1. Default </B><B>ksh.kshrc</B><B> file.</B></FONT>
<BR>
<PRE>
<FONT COLOR="#000080"># NAME
# ksh.kshrc - global initialization for ksh
#
# DESCRIPTION:
# Each invocation of /bin/ksh processes the file pointed
# to by $ENV (usually $HOME/.kshrc).
# This file is intended as a global .kshrc file for the
# Korn shell. A user's $HOME/.kshrc file simply requires
# the line:
# . /etc/ksh.kshrc
# at or near the start to pick up the defaults in this
# file which can then be overridden as desired.
#
# SEE ALSO:
# $HOME/.kshrc
#
# RCSid:
# $Id: ksh.kshrc,v 1.6 93/09/29 08:57:50 sjg Exp $
#
# @(#)Copyright 1991 Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
# Permission to copy, redistribute or otherwise
# use this file is hereby granted provided that
# the above copyright notice and this notice are
# left intact.
case "$-" in
*i*) # we are interactive
# we may have su'ed so reset these
# NOTE: SCO-UNIX doesn't have whoami,
# install whoami.sh
HOSTNAME='hostname'
USER='whoami'
PROMPT="<$USER@$HOSTNAME:!>$ "
PPROMPT='<$USER@$HOSTNAME:$PWD:!>$ '
PS1=$PROMPT
# $TTY is the tty we logged in on,
# $tty is that which we are in now (might by pty)
tty='tty'
tty='basename $tty'
set -o $EDITOR
alias ls='ls -CF'
alias h='fc -l | more'
# the PD ksh is not 100% compatible
case "$KSH_VERSION" in
*PD*) # PD ksh
case "$TERM" in
xterm*)
# bind arrow keys
bind '^[['=prefix-2
bind '^XA'=up-history
bind '^XB'=down-history
bind '^XC'=forward-char
bind '^XD'=backward-char
;;
esac
;;
*) # real ksh ?
;;
esac
case "$TERM" in
sun*)
# these are not as neat as their csh equivalents
if [ "$tty" != console ]; then
# ilabel
ILS='\033]L'; ILE='\033\\'
# window title bar
WLS='\033]l'; WLE='\033\\'
fi
;;
xterm*)
ILS='\033]1;'; ILE='\007'
WLS='\033]2;xterm: '; WLE='\007'
;;
*) ;;
esac
# do we want window decorations?
if [ "$ILS" ]; then
ilabel () { print -n "${ILS}$*${ILE}"; }
label () { print -n "${WLS}$*${WLE}"; }
alias stripe='label "$USER@$HOST ($tty) - $PWD"'
alias istripe='ilabel "$USER@$HOST ($tty)"'
wftp () { ilabel "ftp $*"; "ftp" $*; eval istripe; }
wcd () { "cd" $*; eval stripe; }
wtelnet ()
{
"telnet" "$@"
eval istripe
eval stripe
}
wsu ()
{
"su" "$@"
eval istripe
eval stripe
}
alias su=wsu
alias cd=wcd
alias ftp=wftp
alias telnet=wtelnet
eval stripe
eval istripe
PS1=$PROMPT
fi
alias quit=exit
alias cls=clear
alias logout=exit
alias bye=exit
alias p='ps -l'
alias j=jobs
alias o='fg %-'
# add your favourite aliases here
;;
*) # non-interactive
;;
esac
# commands for both interactive and non-interactive shells</FONT></PRE>
<BR>
<A NAME="E68E74"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>pdksh</B><B> Commands</B></FONT></CENTER></H3>
<BR>
<P>Here are some of the most useful built-in pdksh commands:
<BR>
<UL>
<UL>
<P>. reads and executes the contents of the file. (This will be discussed in more detail in <A HREF="rhl13.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl13.htm">Chapter 13</A>.)
<BR>
</UL></UL>
<UL>
<UL>
<P>alias is used to set aliases, command nicknames that can be defined by the user.
<BR>
</UL></UL>
<UL>
<UL>
<P>bg (background command) forces a suspended process to continue to execute in the background.
<BR>
</UL></UL>
<UL>
<UL>
<P>cd (change working directory) changes the current working directory to the directory specified.
<BR>
</UL></UL>
<UL>
<UL>
<P>exit terminates the shell.
<BR>
</UL></UL>
<UL>
<UL>
<P>export causes the value of a variable to be made visible to all subprocesses that belong to the current shell.
<BR>
</UL></UL>
<UL>
<UL>
<P>fc (fix command) used to edit the commands that are in the current history list.
<BR>
</UL></UL>
<UL>
<UL>
<P>fg (foreground command) forces a suspended process to continue to execute in the foreground.
<BR>
</UL></UL>
<UL>
<UL>
<P>kill is used to terminate another process.
<BR>
</UL></UL>
<UL>
<UL>
<P>pwd (print working directory) prints to the screen the directory in which the user is currently working.
<BR>
</UL></UL>
<UL>
<UL>
<P>unalias is used to remove aliases that have previously been defined using the alias command.
<BR>
</UL></UL>
<BR>
<A NAME="E68E75"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>pdksh</B><B> Variables</B></FONT></CENTER></H3>
<BR>
<P>Some of the most useful pdksh variables are listed next, including the variable name, a short description, and default value (if one exists).
<BR>
<UL>
<UL>
<P>EDITOR, FCEDIT The default editor for the fc bash command.
<BR>
</UL></UL>
<UL>
<UL>
<P>HISTFILE The name of the file that is used to store the command history.
<BR>
</UL></UL>
<UL>
<UL>
<P>HISTSIZE The size of the history list.
<BR>
</UL></UL>
<UL>
<UL>
<P>HOME The HOME directory of the current user
<BR>
</UL></UL>
<UL>
<UL>
<P>OLDPWD The previous working directory (the one that was current before the current directory was entered).
<BR>
</UL></UL>
<UL>
<UL>
<P>PATH The search path that bash uses when looking for executable files.
<BR>
</UL></UL>
<UL>
<UL>
<P>PS1 The first level prompt that is displayed on the command line.
<BR>
</UL></UL>
<UL>
<UL>
<P>PS2 The second level prompt that is displayed when a command is expecting more input.
<BR>
</UL></UL>
<UL>
<UL>
<P>PWD The current working directory.
<BR>
</UL></UL>
<UL>
<UL>
<P>SECONDS The number of seconds that have elapsed since the current bash session was started.
<BR>
</UL></UL>
<BR>
<A NAME="E68E76"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Summary</B></FONT></CENTER></H3>
<BR>
<P>We've looked at many of the features of the Public Domain Korn Shell (pdksh). It is similar to the Bourne Again Shell in many aspects, but it does add some new utilities.
<BR>
<P>In the next chapter, we look at tcsh, a version of the C shell that is available with Linux. After you have seen the features and the way you use the three shells, you should be able to decide which shell is best for you to use on a regular basis. Of
course, you can use any shell at any time by simply typing its name.<A NAME="I2"></A>
<P ALIGN=LEFT>
<A HREF="rhl10.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl10.htm" TARGET="_self"><IMG SRC="purprev.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>
<A HREF="#I0" TARGET="_self"><IMG SRC="purtop.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purtop.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Page Top"></A>
<A HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/index.htm" TARGET="_self"><IMG SRC="purtoc.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purtoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>
<A HREF="rhl12.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl12.htm" TARGET="_self"><IMG SRC="purnext.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purnext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>
</BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?