I use tcsh and have the following in my .cshrc file. But the .history file is not updated as and when I execute a command. Is there anyway so that .history file is updated every time I execute a command ?

set history=500
set savehist=1
set histfile = ~/.history

2 Answers 2


You can manually update the file with history -S

In tcsh, you can make an alias that runs when each command is actually executed:

alias precmd 'history -S'

To have the history preserved between multiple simultaneous sessions, you also want to merge the histories:

alias precmd 'history -S; history -M'

Also - you don't want savehist set to 1 - that will only save one line of history. Instead use:

set savehist (500 merge)

to save 500 lines of history

You must log in to answer this question.

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