#autoload

[ ! -f "${HOME}"/.local/share/zsh/.zsh_dir_hashes ] \
  && touch "${HOME}"/.local/share/zsh/.zsh_dir_hashes

[ -z "$1" ] && echo "Pass hash to use for dir" && return 1
# hash -d "$1"="$(pwd)"
# echo hash -d "$1"=\""$(pwd)"\" >>"${HOME}/.local/share/zsh/.zsh_dir_hashes"
# key="${1%%\=*}" ;  val="${1#*\=}"
# [ -d "${val}" ] && hash -d -- "${key}=${val}"
hash -d -- "$1"="${PWD}"
echo hash -d "$1"=\""${PWD}"\" >>"${HOME}"/.local/share/zsh/.zsh_dir_hashes

# xhashd(): check for directory, then create hash -d
# xhashd() {
#   local key val com
#   if (( ${#argv} == 0 )) ; then
#       printf 'xhashd(): Missing argument.\n'
#       return 1
#   fi
#   if (( ${#argv} > 1 )) ; then
#       printf 'xhashd(): Too many arguments %s\n' "${#argv}"
#       return 1
#   fi
#   key="${1%%\=*}" ;  val="${1#*\=}"
#   [[ -d ${val} ]] && hash -d -- "${key}=${val}"
#   return 0
# }
