Saving current directory to zsh history
Posted
by user130208
on Stack Overflow
See other posts from Stack Overflow
or by user130208
Published on 2010-05-13T02:04:33Z
Indexed on
2010/05/21
1:50 UTC
Read the original article
Hit count: 313
I wanted to achieve the same as asked here http://stackoverflow.com/questions/945288/saving-current-directory-to-bash-history but within zsh shell. I haven't done any zsh trickry before but so far I have:
function precmd {
hpwd=$history[$((HISTCMD-1))]
if [[ $hpwd == "cd" ]]; then
cwd=$OLDPWD
else
cwd=$PWD
fi
hpwd="${hpwd% ### *} ### $cwd"
echo "$hpwd" >>~/.hist_log
}
Right now I save the command annotated with the directory name to a log file. This works fine for me. Just thought there might be a way to make replacement in the history buffer itself.
© Stack Overflow or respective owner