AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.

 View Only
  • 1.  AIX 5.3 Arrow keys for command history

    Posted Thu January 11, 2018 09:06 AM

    Originally posted by: FilipRadil


    HI,

    On my new job i got a IBM 9111-285 machine with AIX 5.3. I am used to using arrow keys for command history 'search?'. You know, up and down arrows for scrolling through recent commands.

    On AIX 5.3 i can't do that. I've done some research and found 2 ways to go around this problem of mine: 

    1. set -o vi, 

    2. set -o emacs.

     

    set -o vi using esc to do this is just a pain in the butt, so i tried with set -o emacs and tried putting the following in the .profile and .kschr files.

    >>set -o emacs

    >>alias __A=$(print -n "\020")

    >>alias __B=$(print -n "\016")

    >>alias __C=$(print -n "\006")

    >>alias __D=$(print -n "\002")

    I've also changed this a little by putting echo instead print and so on, everything i could find online. Nothing. I know when I enter 'set -o emacs' in terminal I can use ^P and ^N to navigate through commands, but that doesn't work on startup.

     

    Now, my question is Can this be done AND how can i do it. From time to time I use commands that i find online and close the site after i found them, and need them again after minute or so and have to find them again, which can take a while.

    I am not an expert or knowledgeable about AIX so precise answers would help me A TON.

    Thank you very much for your help and understanding in advance.

     

    Ty, FR.



  • 2.  Re: AIX 5.3 Arrow keys for command history

    Posted Fri January 12, 2018 11:14 AM

    Originally posted by: Chris_Monk


    Assuming you're using ksh then you are almost there.

    In your .profile set -o emacs and then the alias to be the control char, hence ...

    alias __A="^P"

    __B="^N"

    __C="^F"

    __D="^B"

    To insert the control key precede it with Control-V in vi

    As far as I'm aware this works for all recent ksh versions (88ish on?) on all Unix / Linuxes



  • 3.  Re: AIX 5.3 Arrow keys for command history

    Posted Tue January 16, 2018 05:43 AM

    Originally posted by: FilipRadil


    What do you mean by: "To insert the control key precede it with Control-V in vi", i'm kinda a noob when we're talking about AIX. 

    can you guide me how to expand on what i've writen so far? (in steps)

    ty for your help.

     



  • 4.  Re: AIX 5.3 Arrow keys for command history

    Posted Wed January 17, 2018 07:55 AM

    Originally posted by: Chris_Monk


    Hi,

    I should have enclosed the key sequence with brackets, sorry.

    The sequence to get a control-P character in vi/vim when in insert mode is <Control-v><Control-p>.

    This means press and hold the "control" key, then press the "v" key and release both at the same time.  Next press and hold the "control" key, then press the "p" key and release both at the same time.

    The screen should now display "^P" where the cursor is.

    After you save the file, you can verify that it contains the control character with "cat -v filename".



  • 5.  Re: AIX 5.3 Arrow keys for command history

    Posted Wed February 07, 2018 04:28 AM

    Originally posted by: FilipRadil


    Sorry for answering after a long time, but I've been busy lately. I tried a lot of things and found a solution (after pulling all my hair out).

    1) In .profile I added:

           ENV="$HOME/.kshrc"

           export ENV

    2) I then created .kshrc (touch .kshrc) and inside i added aliases:

           set -o emacs

       alias __A=$(print -n "\020")

       alias __B=$(print -n "\016")

       alias __C=$(print -n "\006")

          alias __D=$(print -n "\002")

     

    After doing all this using arrow keys to go through command history finally works.

    Thank you for your time and help.



  • 6.  Re: AIX 5.3 Arrow keys for command history

    Posted Thu February 08, 2018 07:32 AM

    Originally posted by: Chris_Monk


    No worries, HTH.

    For info of anyone that cares, this arrow sequence I first came across (as in I stole it) on a Sequent running Dynix in the 90's so it's been doable in ksh for a long time.