我希望在zsh shell中达到与Saving current directory to bash history中所述相同的效果。我没有做任何的zsh trickry之前,但到目前为止,我有:将当前目录保存到zsh历史中
function precmd {
hpwd=$history[$((HISTCMD-1))]
if [[ $hpwd == "cd" ]]; then
cwd=$OLDPWD
else
cwd=$PWD
fi
hpwd="${hpwd% ### *} ### $cwd"
echo "$hpwd" >>~/.hist_log
}
现在我保存的目录名到一个日志文件注释的命令。这对我来说很好。只是认为可能有办法在历史缓冲区中进行替换。
可能的重复[我如何(从脚本)添加一些东西到zsh命令的历史?](http://stackoverflow.com/questions/2816225/how-can-i-from-a-script-add - 什么东西到这个zsh命令历史) – 2010-05-13 11:02:53