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!

Last command in csh shell

Status
Not open for further replies.

glj

MIS
Nov 30, 2000
17
0
0
CH
Hi Folks
Is it possible to
use arrow keys to repeat last command ?
I know this can be done with ksh.

I'd like to use csh.
Any scripts or hints appreciated.


 
Not sure about the arrow keys, but check out the history section of the csh man page.
 
Why wouldn't you just type r? Are you trying to get the command shown on the commandline or press the arrow multiple times to scroll through history?

How do you have it set up for ksh?

[morning] needcoffee
 
needcoffee -

just using 'r' does not work under csh, or at least under AIX and Solaris it doesn't.

glj -

If you need to use csh but want the command line completion and the functionality of using arrow keys to scroll through command history, have you considered 'tcsh'? This should give you the best of both worlds.

Regards,
Chuck
 
Easiest way without completely tweaking the CSH is to use the !! command from the prompt.

This will redo the last command.

If your history is setup then you can use !<event #>

ie.
%> echo &quot;HI&quot;
HI
%> !!
HI
%>history
1: echo &quot;HI&quot;
%> !1
 
If you're a VI user, you can use VI line-edit mode on the comand line. To set this up, type:
$ set -o vi
Now you can use standard VI commands to browse the command history, and edit the command (for example, ESC-k to go to the last command, / to search through the command history etc).

This definately works in korn, not so sure about the other shells
 

The set -o <editor> works for bash and korn.

To add to Ranazar's post, set -o emacs will put you into the emacs mode of line editing.
ctrl-p = up or previous command.
ctrl-k = down or next command.
esc-esc = filename completion

The great thing about emacs is that you can edit and use the backspace without having to switch between the &quot;vi command/insert&quot; modes.
 
hi,
I don't know if this may be useful for you.

I use ksh, but when I encounter a csh, becouse the
user application need it, I open a new window, write

aixterm -T ksh&
ksh
set -o vi
and I don't close that window until I am at that customer !

bye
 
the command &quot;r&quot; is an alias for &quot;fc -e -&quot;. similarly, the &quot;history&quot; command is an alias for &quot;fc -l&quot;. i specified my own alias &quot;re&quot; which is &quot;fc -s&quot; so i can type &quot;re 123&quot; to redo command #123, as seen in the fc -l output. the fc man page explains a lot but i still don't understand how &quot;fc -e -&quot; works.

i also use &quot;set -o vi&quot; but i use ViM as my line editor. works great with the syntax highlighting. i &quot;ESC-k&quot; to my command, then press &quot;v&quot; and get a full screen ViM session. you will want to set the variables FCEDIT, EDITOR, and VISUAL to /usr/local/bin/vim or where-ever.

IBM Certified -- AIX 4.3 Obfuscation
 
i forgot my favorite part, though. press ESC then / then your regular expression to find a matching command. so i can type &quot;ESC /apac ENTER&quot; and find the last time i typed out the long, ugly path to my HTML doc directory.

IBM Certified -- AIX 4.3 Obfuscation
 
I use Escape + k button to list previous commands. Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top