Reputation: 121
[Using zsh, but bash possibly same] I am trying to get custom history per-folder, on chdir <folder>
, in pseudo-code:
cd FOLDER
flush current history
update history from file FOLDER/.history
So far, wrapping in alias, running sub-shell, not working for me, don't know enough about it to progress, ie, tried below, which does set HISTFILE for the new subshell, but does not flush out the old history and re-read from new HISTFILE:
function mycd {
chdir $@
export HISTFILE=`pwd`/.history zsh
}
alias cd='chdir;mycd;'
Upvotes: 2
Views: 665
Reputation: 2456
Near as I can tell from the bash man page for history, you might try issuing the following after the export HISTORY
line:
history -cr
(Which apparently means "clear" and "read from current hist file" for the in-memory history list.)
Upvotes: 1