Using ksh, you can also view session history. In doing so, you can get a quick reminder of what you’ve been doing (Code Listing 3.13), reuse commands, and modify commands you’ve already used.
$ ls Complete NewProject bogus2 files public_html testme Completed News chat.conf ftp puppy Mail access dead.letter mail temp $ ls Complete NewProject bogus2 files public_html testme Completed News chat.conf ftp puppy Mail access dead.letter mail temp $ $ history 56 cd .. 57 ls 58 lynx 59 ls temp 60 more Complete 61 ls 62 more testme 63 ls 64 ls 65 history 66 lynx 67 ftp ftp.raycomm.com 68 ls 69 ls 70 ls 71 history $ r 64 ls Complete NewProject bogus2 files public_html testme Completed News chat.conf ftp puppy Mail access dead.letter mail temp $ |
1. | set -o emacs To begin, you must enter set -o emacs. This command enables history reuse and command completion, and sets the shell to use emacs commands. (Emacs is an editor, but you do not need to use or be familiar with it for now.) If you’ve already done this during your current session, you don’t need to do it again. | ||||||||||||||||||
2. | Use the shell for a little while, changing directories, redirecting output, or doing other tasks. | ||||||||||||||||||
3. | Recall the previous command with . Table 3.2 shows you other keyboard combinations that you can use to navigate through the session history.
After you’ve finished recalling and, optionally, editing the command, press (you don’t have to be at the end of the line to do so). | ||||||||||||||||||
4. | history Type history at the shell prompt to see the list of the most recent commands you’ve entered (Code Listing 3.13). Notice the command number by each command. You can type and the command’s number to rerun it. |
✓ Tip
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.