Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to add the date to my tcsh history information and I can't seem to figure out how to make it work. The tcsh man page reads like this for the history setting:

The first word indicates the number of history events to save. The optional second word (+) indicates the format in which history is printed; if not given, `%h\t%T\t%R\n' is used. The format sequences are described below under prompt; note the variable meaning of %R'. Set to100' by default.

I've tried the following put a line in my .cshrc file using what they say is the default format, but I get an error every time I source. Here is what I've tried (with the resulting error in brackets):

set history = 2000 '%h\t%T\t%R\n' [set: Variable name must begin with a letter.]
set history = 2000 %h\t%T\t%R\n [set: Variable name must begin with a letter.]
set history = 2000 $DATE='%h\t%T\t%R\n' [DATE: Undefined variable.]
set history = 2000 $FORMAT='%h\t%T\t%R\n' [FORMAT: Undefined variable.]
set history = 2000 $TIME='%h\t%T\t%R\n' [TIME: Undefined variable.]

The following doesn't give me a source error, it gives me a history: Badly formed number. error when I try to use history:

set history = '2000 %h\t%T\t%R\n'

I'm obviously just thrashing around here, I don't have a lot of experience with modifying the .cshrc file. Any help would be appreciated.

share|improve this question

1 Answer 1

Try with this syntax:

set history=(2000 "%h\t%T\t%R\n")

To get a full date:

set history=(2000 "%h %D/%W/%Y %T %R\n")

Demo:

$ set history=(2000 "%h %D/%W/%Y %T %R\n")
$ history 
     1 20/05/2011 6:27 set prompt="$ "
     2 20/05/2011 6:27 set history= ( 2000 "%h %D/%W/%Y %T %R\n" )
     3 20/05/2011 6:27 history
share|improve this answer
1  
That worked great, thanks! –  Sanjuro May 24 '11 at 17:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.