A single global history file is generally not what is desired, as it garbles command sequences when working on several tabs simultaneously.
If you want to keep your history PER TAB, use this approach:
set histfile=~/.history_`tty|sed "s#^.*/##"`
set history=1000
set savehist=(${history} merge)
alias postcmd 'history -S'
This will create individual history files for each tab, depending on their tty ID.
Using xfce4-terminal, if you do not change the order of tabs, and don't close tabs except the rightmost ones, this will correctly restore each history to its associated tab (and therefore, path).
As re-ordering tabs takes the tty ID with them, but a xfwm4 session restore will re-create each tab from scratch (assigning new tty IDs starting from 0), it would restore the history files to the "wrong" tab (i.e., not the one with the directory path of their original tab). I haven't found a solution yet how to keep track of these changes.
history
, seeman tcsh
. Searching forhistory -S
should jump you to the most relevant part.