Oct 13 2009

Command History with Arrow Keys in ksh

Published by at 11:48 am under Aix,Linux,Misc,Solaris

Arrows aren’t used in ksh as a default. To enable command history like in Bash, add the following lines in the .profile or .kshrc file:

# Switch to Emacs mode
# Only Emacs mode lets you make use of arrow keys
set -o emacs

# Go back in command history (up arrow)
alias __A='^P'

# Go back in command history (down arrow)
alias __B='^N'

# Move right on the command line (right arrow)
alias __C='^F'

# Move left on the command line (left arrow)
alias __D='^B'

^P, ^N, etc aren’t one single character. Enter Ctrl-V and Ctrl-P to display them in vi.
Auto-completion is only available for files, not commands. Press either twice on the escape key, or the tab key on newer systems.

One response so far

One Response to “Command History with Arrow Keys in ksh”

  1. Anacreoon 05 Jun 2012 at 6:27 pm

    Thank you very much! I am new to AIX and was hating life, now I\’m happy.

    Here is a UUENCODED version of the file for those that can\’t figure out the control characters…

    Copy and paste the below text into a file and then uudecode…

    $ cat | uudecode


    begin 644 .kshrc

Comments RSS

Leave a Reply