function _-accept-line() {
[[ -z "${BUFFER" ]] || [[ "${BUFFER}" =~ "### ${(q)PWD}\$" ]] || BUFFER="${BUFFER} ### ${PWD}"
zle .accept-line
}
zle -N accept-line _-accept-line
Add ### ${PWD}to your command line. Not the best solution you could use, but it works.
UPD: Answer based on @Dennis Williamson's comment:
function zshaddhistory() {
print -sr "${1%%$'\n'} ### ${PWD}"
fc -p
}
source
share