How to let key arrow retrive history commands when remote login sh

How to let key arrow retrive history commands when remote login sh

Post by Joh » Sun, 12 Jan 2003 04:30:13



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.

Thanks lots

--
J.Wu
Toronto

 
 
 

How to let key arrow retrive history commands when remote login sh

Post by Ian Springe » Sun, 12 Jan 2003 07:28:32


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

 
 
 

1. Use arrow keys to retrive commands

I use tcsh because I can use up arrow and down arrow keys to retrieve any
previously entered commands, like doskey.  But csh (not tcsh) is more
widely available.  Is there a way to do the same thing in csh?  I know I
can use !3 to rerun command #3, but that's not as convenient as using
arrow keys.  Thanks!

-Zhihui

2. missing /dev/modem

3. How to remap arrow keys for last command (history)

4. Routing through PPPoTCP

5. How to Display history command using arrow keys

6. Adv. Solaris Sys Admin Class; Boston, MA; 8/25/95

7. KSH-Using arrows keys with command history in VI mode.

8. Solaris on sparc ipx

9. arrow keys and command history

10. How to make the up arrow and down arrow to keep the command history?

11. How to make arrow keys go through your command history?

12. ksh command history and arrow keys

13. vi, ksh, Command History, and Arrow Keys: Impossible?