Publishers of technology books, eBooks, and videos for creative people

Home > Articles

  • Print
  • + Share This
This chapter is from the book

Using Completion in the ksh Shell

ksh is another shell that offers command completion. You type part of a command, press esc.jpg 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 escesc.jpg

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

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

  • + Share This
  • 🔖 Save To Your Account