Using Completion in the ksh Shell


Using Completion in the ksh Shell

ksh is another shell that offers command completion. You type part of a command, press twice, and ksh completes the command for you (see Code Listing 3.12). Using command completion in ksh isn't as easy as it is in zsh or bash, but the results are the same.

Code Listing 3.12. After listing the files and directories, we set our options, then successfully completed a command. The ^[^[ is how appears on the screen when the shell doesn't know to use it to complete commands.

$ ls Complete NewProject bogus2 files  public_html testme Completed    News    chat.conf  ftp   puppy Mail access dead.letter  mail  temp $    cd pub^[^[ ksh: pub:  not found $    set -o emacs $ cd public_html/ $ 

To use completion in the ksh shell:

1.

set -o emacs

To begin, you must enable command completion by entering set -o emacs. This command enables command completion and sets it to use emacs commands. (Emacs is an editor, but you do not need to use or be familiar with it to recycle ksh commands.)

2.

ls -l

Use ls -l to list the files in your current directory. You do this so you know which directory (public_html) you can change to in step 3.

3.

cd pub

Type in a partial command. In this example, we typed the cd command and part of the public_html command (truncated to pub).

Press two times to complete the command. (Depending on your terminal emulation, you might need to use twice instead of twice.)

Tips

  • If you don't have ksh installed on your system, you might also look for pdksh, which is a freely distributable and nearly identical version of ksh.

  • You can also type in set -o vi to use vi commands (instead of the command given in step 1). We've found, though, that this isn't as intuitive or effective, so we recommend the emacs mode.

  • See Chapter 4 for more information about editors.

  • If you use ksh, you'll probably want to add the set -o emacs command to your personal configuration files so you don't have to manually enter the command in each session. See Chapter 8 for the specifics of editing configuration files.





Unix(c) Visual Quickstart Guide
UNIX, Third Edition
ISBN: 0321442458
EAN: 2147483647
Year: 2006
Pages: 251

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net