Search code examples
linuxterminalaix

AIX - Default shell - Arrow keys


I am using AIX machine. I have a concern. I use MobaXterm to access the AIX server. I expected the upward arrow key to give me the previously issued command. Instead it simply goes up as in some editor. The same behavior is observed with down arrow key. How can I get rid of this behaviour?

The shell is ksh.

Thanks.


Solution

  • You'll see that sort of behavior when the terminal sends normal-mode cursor keys. ksh may be looking for application-mode keys, or (more likely) hasn't been told how to handle this. You may get it to work using

    set -o emacs
    

    but may also need to establish key-bindings (found in the first link):

    #
    # The ksh has an undocumented way of binding the arrow keys to the emacs
    # line editing commands. In your .kshrc or in your .profile, add:
    
    alias __A=`echo "\020"` # up arrow = ^p = back a command
    alias __B=`echo "\016"` # down arrow = ^n = down a command
    alias __C=`echo "\006"` # right arrow = ^f = forward a character
    alias __D=`echo "\002"` # left arrow = ^b = back a character
    alias __H=`echo "\001"` # home = ^a = start of line
    
    # Type "set -o emacs" or put this line in your .profile.
    set -o emacs
    

    In a quick check, this works for me, with normal-mode keys.

    Further reading: