3 ms·
Bear in mind I think this is pretty crazy and I haven't tested the following, but something along these lines added to your .bashrc should work: set_per_di
by brbsix 10y ago
Bear in mind I think this is pretty crazy and I haven't tested the following, but something along these lines added to your .bashrc should work:
set_per_dir_history(){
history -a # append new history lines to the existing history file
history -c # clear history list in memory
export HISTFILE=$PWD/.bash_history # set new history file (uses .bash_history in the current directory)
history -r # read the new history file into memory
}
export PROMPT_COMMAND="set_per_dir_history;$PROMPT_COMMAND"
Personally I'd add some additional logic to the set_per_dir_history function, defaulting to ~/.bash_history and only whitelisting specific directories.
- andrewfromx 10y agoi wonder why this isn't default bash history behavior? Wouldn't it be way more useful this way?