PTC MKS Toolkit Knowledge Base

Section:IO
Product:MKS Toolkit (All)
Version:
OS:All
Keywords:scroll, history
Category:Utilities/Knowledge Base


How do I scroll through my command history?


KornShell:
In VI editing mode (the default, or can be set with set –o vi) press ESC to switch to command mode then use "j" and "k" to scroll through your command history. You can set -o emacs or set -o gmacs to switch to emacs or gmacs editing modes. In these modes you use the cursor keys to scroll through your command history and edit commands. You can automate this selection by adding the command to your environ.ksh script. This script is in your HOME directory. For those with a DOS background you will find these modes similar to having DOSKEY enabled.

Bash:
The default command-line editing mode in bash is set -o emacs and behaves as mentioned above.

C Shell:
The C Shell does not directly support scrolling through the command history. However, history will display a list of the most recently executed commands. The following commands can then be used to repeat something from the history list.

    !! — Repeat the last command
    !n — Repeat command number n from the history list
    !-n — Repeat the n-th most recent command
    !str — Repeat the last command that begins with str
    !?str — Repeat the last command that contains str

Note that the history shell variable must be set for C Shell to maintain a history list. set history = 10 will force it to remember the last 10 commands. You can automate this setting by adding the command to your cshrc.csh script.