Home Databases Development Genealogy Operating Systems Miscellaneous Help

FAQ

Section Command line history i ksh

Set the invironment:
HISTFILE=${HOME}/.sh_history
HISTSIZE=3000
set -o emacs

Section How can I activate command line history with arrow keys?

Based on:
http://www.ifw-dresden.de/~ulrike/FAQ/#a3

ksh is initially in vi mode. In this mode you can use command line history with the (cryptic) vi commands (e.g. ESC-k for the previous command or ESC-/ for the last command in the command history containing string).

To use the arrow keys you have to switch to emacs mode. Then you can use the (also cryptic) emacs commands for editing the command line (e.g. CTRL-P for the previous command or CTRL-R string for the last command in the command line history containing string) and you can bind some emacs commands to arrow keys. Insert in your .profile or your ENVIRONMENT file the following lines:


set -o emacs # set emacs mode
alias __A="^P" # arrow key for the previous command
alias __B="^N" # arrow key for the next command
alias __C="^F" # arrow key for one character forwards
alias __D="^B" # arrow key for one character backwards

To insert ^P press CTRL-V CTRL-P.