- Discovering What Shell You're Using
- Understanding Shells and Options
- Changing Your Shell with chsh
- Changing Your Shell Temporarily
- Using Completion in the bash Shell
- Viewing Session History in the bash Shell
- Using Completion in the zsh Shell
- Viewing Session History in the zsh Shell
- Using Completion in the ksh Shell
- Viewing Session History in the ksh Shell
- Viewing Session History in the csh Shell
- Changing Your Identity with su
- Fixing Terminal Settings with stty
- Exiting the Shell
Viewing Session History in the ksh Shell
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.
Code Listing 3.13. Although it looks like we typed ls for both the first and second commands, we really just pressed to get the second ls command. The r 64 command recycles the command numbered 64 in the list.
$ 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 $
To view session history in the ksh shell:
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.
- Use the shell for a little while, changing directories, redirecting output, or doing other tasks.
Recall the previous command with . Table 3.2 shows you other keyboard combinations that you can use to navigate through the session history.
Table 3.2. ksh History Navigation Commands
Recalls the previous command
Recalls the next command (works only after you've moved to a previous command)
Gets the previous command containing "something"
Moves back one character within a command
Moves forward one character within a command
Goes to the beginning of the line within a command
Goes to the end of the line within a command
Deletes the current character
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).
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.