1
0
Fork 0
mirror of synced 2024-06-25 18:01:09 -04:00
zimfw/modules/prompt/functions/short_pwd
Cenk Gündoğan fcc4c573a8 [prompt] fix gitster path to reflect git repo
allow optional parameter for short_pwd

Closes #41
2016-04-02 13:33:01 -07:00

14 lines
315 B
Plaintext

# shortens the pwd for use in prompt
local current_dir="${1:-${PWD}}"
local return_dir='~'
current_dir="${current_dir/#${HOME}/~}"
# if we aren't in ~
if [[ ${current_dir} != '~' ]]; then
return_dir="${${${${(@j:/:M)${(@s:/:)current_dir}##.#?}:h}%/}//\%/%%}/${${current_dir:t}//\%/%%}"
fi
print ${return_dir}