Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2006
    Posts
    56

    Unanswered: Hot key in Korn shell?

    I want to be able to use the arrow keys (up and down) to cycle through the commands I have already executed. Is this possile? I can do it on a DOS prompt.

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    I prefer
    set -o vi
    this allow me to use vi to edit the commands I type
    just hit escape and use normal vi commands to edit the line
    and
    <esc-k><k><k><k> to scroll back thru previous 3 commands
    <esc-j><j><j> to scroll forward 2 commands

    But to answer your question
    Code:
    #!/bin/ksh
    # file: enable-arrows
    # source in current environment with
    # command:
    #       . enable-arrows
    #
    
    set -o emacs
    
    # Note: these are the actual control
    # characters. In vi, type ctrl-v
    # then ctrl-P (if u want a ctrl-p)
    alias _A=^P
    alias _B=^N
    alias _D=^B
    alias _C=^F
    
    alias __A=^P
    alias __B=^N
    alias __D=^B
    alias __C=^F

  3. #3
    Join Date
    Aug 2006
    Posts
    56
    Ok, I copied the script and executed it. But I am not sure how to use it (I don't use Unix often)

  4. #4
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    248
    Writing the lines in your .profile, or importing the script into the .profile with the line:
    Code:
    . path/enable-arrows
    makes the functionality always available...

    BTW. Your requested behaviour is standard for the bash-shell in many (if not all) Linux distributions. I don't miss anything I had in ksh, so if it's available on your system...
    Last edited by Tyveleyn; 09-20-06 at 17:35.

  5. #5
    Join Date
    Aug 2006
    Posts
    56
    It's a development account, so I cannot touch the .profile. I just don't know which keys are used for navigation once I execute the script.

  6. #6
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    248
    I just don't know which keys are used for navigation once I execute the script.
    what do you mean by that? If the script doesn't make the cursor keys function like you wanted then probably you didn't enter the control characters the right way. Do it as pdreyer described:
    In vi, first type ctrl-v, then ctrl-P (if u want a ^P)
    Be sure the script is executable and make it's code effective in your current shell with
    Code:
    . enable-arrows
    on the prompt. Works fine in my ksh under AIX.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •