SUMMARY: Enable arrow keys to repeat last command

From: Rasana Atreya (
Date: Thu Dec 19 1996 - 11:35:17 CST


I asked (long ago, I admit):

>I have a Sparc 2 with Solaris 2.5. Open Windows and xterms. Is it possible to
>use arrow keys to repeat last command (loop) i.e. reading history file
>starting from latest command typed? I know this can be done with bash, but
>I'd like to use csh. Any scripts or hints appreciated.

Most people suggested tcsh. I'm including relevant parts of people's
suggestions. Thanks to everyone for their time and efforts (esp. Raju
Krishnamurthy - time and effort taking on special meaning here!), and to
Niall O Broin - Gray Wizard also for his free philosophic observations! ;)

Thanks again!

From: (Kevin Sheehan {Consulting Poster Child})
From: Michael Panayiotakis <>

************ (Niall O Broin - Gray Wizard)
> I know this can be done with bash

You answer your own question.

> but I'd like to use csh.

I'd like to drive at Porsche speeds, but I prefer my Yugo :-) No can do !
Offhand, I can't think of anything I've ever wanted to do in csh that I
couldn't do at least as easily in bash (and I used csh for years before
converting to bash), apart from aliases with arguments, which functionality
can be provided with shell functions. Bash is of course a bigger consumer of
resources than csh but if that's your problem, then you've got bigger problems
too :-)

An alternative might be tcsh which is an enhanced csh - I don't use it but
I've attached a compressed copy of its man page for your perusal.

From: Tom Schmidt <>
It also allows you to edit the previous history commands using emacs
like editing keys.

From: Reto Lichtensteiger <>
tcsh will do all that and more -- command line editting flavors can be
either emacs style of vi style; spell checking of commands etc.

From: (Sajjad Ahmed) <>
Have you tried tcsh? It has the loop feature, using the up & down arrow
keys. It is also almost entirely upwardly compatible with csh.
Ref: `Using csh & tcsh 'Paul Dubois ( O'Reilly & Associates )1995.

From: Stanislav Protassov <>
tcsh (precompiled):

From: "Yaron Hemi, Trendline LTD." <>
You can find tcsh at in /pub/freeware or something. (:

From: (Thomas White)
explained history feature of csh.

From: (Dale Wiles)
From: (Jafar Shameem)
From: rangern@CIRANO.UMontreal.CA (Normand Ranger)
From: "Brian T. Wightman" <>
From: (Craig L. Gruneberg)
From: (David Procter)
From: (Karlheinz Pischke)
From: rauthenberg@HHI.DE (Stefan Rauthenberg)
From: "Gokhan Ozkan" <>
Sanjay Gowda

From: (Laurent Delfosse)

.cshrc, and essentially runs just like csh (except it has cool added features,
like watch) and has builtin arrow key to history commands support. It
also has builtin emacs command support for editing the command line :)
(in case you use emacs).

From: "Mark P. Beckman" <>

Errr, run fvwm as your window manager?

That's what I do on my linux boxes, and I'm running under csh on them.

From: Raju Krishnamurthy - Senior Software Engineer


I use tcsh (GNU archive), it's based on csh with added features. It allows
you to use the up/down arrows to traverse the history as well as the
familiar '!' format from csh. Another nice thing is that it has
'filename completion' meaning that you can use <TAB> to complete
file/command/host names if they name is ambigious, otherwise it give
you a list of possible items.

here's an example:

tcsh> ls -al
total 45
drwxr-xr-x 2 raju 1024 Nov 13 09:09 ./
drwxr-xr-x 31 raju 1536 Nov 12 17:38 ../
- - -rw-r--r-- 1 raju 146 Oct 29 12:46 .Xauthority
- - -rw-r--r-- 1 raju 4127 Oct 29 12:46 .Xdefaults
- - -rw-r--r-- 1 raju 1184 Oct 29 12:46 .Xresources
- - -rwx--x--x 1 raju 2799 Oct 29 12:49 .Xsession*
- - -rw-r--r-- 1 raju 166 Oct 29 12:48 .aliases
- - -rw-r--r-- 1 raju 11732 Oct 29 12:46 .complete
- - -rw-r--r-- 1 raju 1918 Oct 29 12:46 .cshrc
- - -rw-r--r-- 1 raju 0 Nov 13 09:09
- - -rw-r--r-- 1 raju 759 Oct 29 12:46 .login
- - -rw-r--r-- 1 raju 100 Oct 29 12:48 .mailrc
- - -rw-r--r-- 1 raju 498 Oct 29 12:46 .newsrc
- - -rw-r--r-- 1 raju 956 Oct 29 12:49 .tcshrc
- - -rw-r--r-- 1 raju 7945 Oct 29 12:46 .twmrc
- - -rwx--x--x 1 raju 2799 Oct 29 12:46 .xinitrc*
- - -rw-r--r-- 1 raju 147 Oct 29 12:46 .xmod
tcsh> vi .c<TAB>
.complete .cshrc
tcsh> vi .cs<TAB>
tcsh> vi .cshrc

I want to edit .cshrc, here's what happened:

1) 'ls' to show what file I've got
2) typed "vi .c" followed by a <tab>, there are three file that
   start with ".c", tcsh shows them to me, and gives me a new command
   line with "vi .c"
3) I typed in the letter "s" and hit <tab>, tcsh completes upto
   "vi .cshrc" where it becomes ambigious ...

Another nice feature of tcsh is that you can configure it to complete
specific things based on the situation. For example, if I'm trying to
'cd', tcsh should only complete directory names not *all* files, or
'uncompress' should only consider files that end with '.Z' ...

Well, I think you get the idea ... I use it cause I type about 10 word/min
on a good day, anyway this message took me 45 minutes to write ;-)

good luck,


~ Rasana Atreya Voice: (415) 476-3623 ~
~ System Administrator Fax: (415) 476-4653 ~
~ Library & Ctr for Knowledge Mgmt, Univ. of California at San Francisco ~
~ 530 Parnassus Ave, Box 0840, San Francisco, CA 94143-0840 ~
~ ~

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:18 CDT