# shortens the pwd for use in prompt

local current_dir="${PWD/#${HOME}/~}"
local return_dir='~'

# if we aren't in ~
if [[ ${current_dir} != '~' ]]; then
  return_dir="${${${${(@j:/:M)${(@s:/:)current_dir}##.#?}:h}%/}//\%/%%}/${${current_dir:t}//\%/%%}"
fi

print ${return_dir}