5

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.

1 Answer 1

6

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
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .