Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

command History

Status
Not open for further replies.

drkestrel

MIS
Sep 25, 2000
439
0
0
GB
Running Sun Solaris UNIX(Sun OS5.6) and ksh(i think) and Common Desktop Interface.

Somehow, getting to the command history by using the up/down arrow keys doesn't work. I tried running
Code:
csh
and sh (by typing in
Code:
csh/sh
at the terminal) but that didn't help either!! Anyone know how I could get this working? Note that the
Code:
history
and also
Code:
!!
do work.

 
Well, if you're using ksh (type echo $SHELL to see) you can type "set -o vi" and whenever you type "[esc]+k" you can scroll back through your history and if you type "[esc]+\" and the word or beginning letter of a command it will go straight to it instead of having to scroll back through all of your history to find it. d3funct
borg@pcgeek.net
The software required `Windows 95 or better', so I installed Linux.

 
defintely my shell is set to /bin/ksh. But after logging in, and typing
Code:
set -o vi
. The up and down arrow keys cannot still be used to get to 'command history'!!
All I get is some rubbish like ^[OA and a BEEP!!
What should I do!!
 
By typing set -o vi, you are setting your command line editor to the vi editor. To bring up the last executed command, type ESC k (i.e. hit the Escape key, then the k key). Now you can use the standard vi controls to edit the line. Hope you are familiar with vi though. If not, I think you can (in theory) use anything as your command line editor, so if you use Emacs, you may be able to do a set -o emacs. Haven't tried that though.

Greg.
 
Check if you have set a proper Terminal. you can see if it is correct if you have a proper function of the vi-Editor.

hnd
hasso55@yahoo.com

 
Try ESC- (Escape key then the minus key) to scroll backwards through the command history in ksh and ESC+ to scroll forward.

Mike
michael.j.lacey@ntlworld.com
 
Esc- and Esc+ works but I am pretty sure when I was using tcsh with Redhat Linux 6.1, the Up/Down arrow key just works fine without me setting anything!

Could I do the same with ksh??
 
sorry drkestrel, I've never needed to do that
Mike
michael.j.lacey@ntlworld.com
 
MikeLacey: do you mean you always get to scroll through command history using up/down arrow keys already?? I thought it is usual as well! It hasn't got anything to do with the Windows manager, I guess??

Anyone used KSH and get up/down arrows working?
 
I have my sessions with ksh. And my editor set to emacs..
Warning: You will only have in the history what you typed in !after! the set -o command!. It's all stored in a file in you home directory. Also, it saved for future sessions!. Almos like a log of everything you do. Someday the file will be huge enough for it to be a bother!

do this;

ksh
set -o emacs

Do a few different "ls" commands... Then try to use up and down.


Luck!
Life is good!, live it?
 
Nope - I've just always used the -+ keys
Mike
michael.j.lacey@ntlworld.com
 
Don't try to bind the up/down keys to the command history recall function. You simply can't do that with ksh when the vi or viraw modes are set. But try downloading and installing bash... it have what you want.

I hope it works...
 
Hi,
The problem may be with terminal settings.Like hasssos suggestion you try using "[esc]+ J" and "[esc]+K" keys for scrolling down or up to get the command history..

Suresh.
 
Using the up/down arrows to go through the history is a feature of the BASH shell. Says the Manager to the person that invented the modem: "Tell me again why you need two prototypes?!?"
 
I am using Bash and when I goto use history clear it says bad numeric value and I was wondering if there is another command to clear the history file???
 
Hey Mike -- the ESC+- tip is great, however I cannot edit the line once I get to it... ksh (on my machine anyway) doesn't seem to like the right/left arrows either. Any ideas? Thanks.
 
you can use vi commands to edit the line, the arrow keys don't work but 'h' moves you left and 'l' right Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Cool... I can use space and backspace to get where I want to be, then x, i, or a accordingly, as in vi. It'll take some getting used to, but gets the job done. Thanks!
 
the '/', 'n' and 'p' commands work like vi as well

'/pg my' searches command history, will match 'pg myfile'
'n' searches command history for next command that will match
'p' searches command history for previous command that will match Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top