Quote:> I'm wondering how to set something to let key arrow retrive history
> commands in sh. say I always remote login and have to work in sh, but
> when pressing the arrow-like key, it displays something like ^[[A, but
> in tcsh, it can display the previous typed commands.
The following works for ksh and for sh's that are based on the ksh source
code such as HP-UX's POSIX sh:
#
# Aliases to make the keys in emacs command mode behave as they do in DOS;
# this mapping mechanism is an undocumented ksh feature; works in xterm &
# dtterm, but not hpterm
#
# Key(s) Emacs mode command
#==========================================================================
alias __A=`echo "\020"` # up arrow -> Ctrl-P (previous cmd)
alias __B=`echo "\016"` # down arrow -> Ctrl-N (next cmd)
alias __C=`echo "\006"` # right arrow -> Ctrl-F (move forward 1 char)
alias __D=`echo "\002"` # left arrow -> Ctrl-B (move backward 1 char)
alias __P=`echo "\004"` # delete -> Ctrl-D (delete char under cursor)
# NOTE: below aliases don't work on a PC running a Windows X server:
alias __H=`echo "\001"` # home -> Ctrl-A (go to beginning of line)
alias __Q=`echo "\005"` # end -> Ctrl-E (go to end of line)
alias __Z=`echo "\007"` # clear? -> Ctrl-G (clear line)
# NOTE: this is a weird one that skips interpretation of emacs mode
commands,
# so I use it to just print the system model and OS
INFO="### $(model) - $(uname -sr) ### "
alias __1=$INFO # F1-F8