Before install create a backup of your .bash_history
, then clone this
repository to your home directory:
cd ~
git clone https://github.com/martinec/bash-per-directory-history.git .bash-per-directory-history
and append the next line at the bottom of your ~/.bashrc
:
source ~/.bash-per-directory-history/per-directory-history.sh
Alternatively, to ensure sync between the bash memory and the history file, for example to share the history across all open terminals, you can instead append:
source ~/.bash-per-directory-history/per-directory-history.sh
PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND"
HSTR is a shell history suggest box for bash and zsh.
This is the suggested configuration in order to use bash-per-directory-history
with HSTR:
# HSTR
alias hh=hstr # hh to be alias for hstr
export HSTR_CONFIG=hicolor # get more colors
# if this is interactive shell, then bind hstr to Ctrl-r (for Vi mode check doc)
if [[ $- =~ .*i.* ]]; then bind '"\C-r": "\C-a hstr -- \C-j"'; fi
# if this is interactive shell, then bind 'kill last command' to Ctrl-x k
if [[ $- =~ .*i.* ]]; then bind '"\C-xk": "\C-a hstr -k \C-j"'; fi
# bash-per-directory-history
source ~/.bash-per-directory-history/per-directory-history.sh
PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND"
- Per directory history.
- Global history with
gistory
command. - Enhanced
cd
(using behindpushd
andpopd
as replacement). - Spell suggestions for mistyped directory names.
- Preserve history no matter if a directory has been moved or renamed (same filesystem).
- Add-ons:
faster-history-navigation
,smarter-tab-completion
,better-bash-history
. - ShellCheck-compliant code.
Please use the GitHub issue tracker for any bugs or feature suggestions:
https://github.com/martinec/bash-per-directory-history/issues
Everyone is welcome to contribute! Fork us and request a pull to the develop branch.