Created
April 10, 2011 11:59
-
-
Save pielgrzym/912281 to your computer and use it in GitHub Desktop.
Zsh history tweaking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
freeze_hist() { | |
fc -p # pop current history into stack | |
HISTFILE=`pwd`/.zsh_custom_history | |
SAVEHIST=10000 | |
HISTSIZE=10000 | |
} | |
unfreeze_hist() { | |
fc -p `pwd`/.zsh_custom_history | |
HISTFILE=`pwd`/.zsh_custom_history | |
SAVEHIST=10000 | |
HISTSIZE=10000 | |
} | |
HBD="/home/pielgrzym/var/hist_test" | |
HBD_LOCK=0 | |
chpwd() { | |
if [[ $PWD = $HBD* && $HBD_LOCK -eq 0 ]] | |
then | |
HBD_LOCK=1 | |
echo "Setting the lock" | |
if [[ -s .zsh_custom_history && -r .zsh_custom_history && -w .zsh_custom_history ]] | |
then | |
echo "Unfreezing history!" | |
unfreeze_hist | |
fi | |
fi | |
if [[ $PWD != $HBD* && $HBD_LOCK -ne 0 ]] | |
then | |
HBD_LOCK=0 | |
echo "Resetting the lock" | |
fc -P | |
echo "Restoring global history" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment