< Day Day Up > |
9.13. New Features of the Interactive TC ShellThe TC shell is a public domain enhanced version of its predecessor, the Berkeley UNIX C shell. If you are using Linux, you will have this available to you rather than the traditional C shell. Although tcsh is included in most Linux distributions, it can also be ported to a number of other operating systems, including Solaris, Windows NT, HP-UX, QNX, and more. There are an assortment of new features in the TC shell. The remainder of this chapter covers these additional features, most of them shortcuts, including command-line editing, fancy prompts, programmable completions (filenames, commands, and variables), spelling correction, and so forth. This section focuses only on the new features added to the TC shell. The topics covered in the last section apply to both the C shell and TC shell. 9.13.1 Versions of tcshTo find out what version of tcsh you are using, type at the shell prompt: which tcsh To tell you in what directory tcsh is installed (normally /bin), and to print the version information, type: /directory_path/tcsh -c 'echo $version' Example 9.69.1 which tcsh /bin/tcsh 2 /bin/tcsh -c 'echo $version' tcsh 6.07.09 (Astron) 1998-07-07 (i386-intel-linux) options 8b,nls,dl,al,rh,color 9.13.2 The Shell PromptsThe TC shell has three prompts: the primary prompt, a > symbol; the secondary prompt, a question mark (?) followed by a tcsh command such as while, foreach, or if; and a third prompt used for the spelling correction feature. The primary prompt is the prompt that is displayed on the terminal after you have logged in. It can be reset. If you are writing scripts at the prompt that require tcsh programming constructs, for example, decision making or looping, the secondary prompt will appear so that you can continue on to the next line. It will continue to appear after each newline, until the construct has been properly terminated. The third prompt appears to confirm automatic spelling correction if spelling correction is turned on. (See "TC Shell Spelling Correction" on page 490.) It contains the string CORRECT > corrected command (y|n|e|a)?. The prompts can be customized by adding special formatting sequences to the prompt string. See Table 9.9.
The Primary Prompt.When running interactively, the prompt waits for you to type a command and press the Enter key. If you do not want to use the default prompt, reset it in the .tcshrc file and it will be set for this and all TC shells subsequently started. If you only want it set for this login session, set it at the shell prompt. Example 9.70.1 > set prompt = '[ %n@%m %c]# ' 2 [ ellie@homebound ~]# cd .. 3 [ ellie@homebound /home]# cd .. EXPLANATION
The Secondary Prompt.The secondary prompt appears when you are writing online scripts at the prompt. The secondary prompt can be changed. Whenever shell programming constructs are entered, followed by a newline, the secondary prompt appears and continues to appear until the construct is properly terminated. Writing scripts correctly at the prompt takes practice. Once the command is entered and you press Enter, you cannot back up, and the tcsh history mechanism does not save commands typed at the secondary prompt. Example 9.71.1 > foreach pal (joe tom ann) 2 foreach? echo Hi $pal 3 foreach? end Hi joe Hi tom Hi ann 4 > EXPLANATION
Example 9.72.1 > set prompt2='%R %% ' 2 > foreach name ( joe tom ann ) 3 foreach % echo Hi $name 4 foreach % end Hi joe Hi tom Hi ann 5 > EXPLANATION
|
< Day Day Up > |