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

    ctrl-d

    begin 644 .kshrc
    M(R!3=VET8V@@=&\@16UA8W,@;6]D90HC($]N;’D@16UA8W,@;6]D92!L971S
    M(‘EO=2!M86ME(‘5S92!O9B!A<G)O=R!K97ES"G-E="`M;R!E;6%C2`H=7`@87)R;W<I"F%L:6%S(%]?
    M03TG$"2`H9&]W;B!A<G)O
    M=RD*86QI87,@7U]"/2<.)PHC($UO=F4@<FEG:'0@;VX@=&AE(&-O;6UA;F0@
    M;&EN92`H<FEG:'0@87)R;W<I"F%L:6%S(%]?0STG!B<*(R!-;W9E(&QE9G0@
    M;VX@=&AE(&-O;6UA;F0@;&EN92`H;&5F="!A<G)O=RD*86QI87,@7U]$/2<"
    ")PH@
    `
    end

Comments RSS

Leave a Reply