1
0
Fork 0
mirror of synced 2024-12-26 16:03:21 -05:00

[prompt] Simplify short_pwd function

We don't need a second variable.
This commit is contained in:
Eric Nielsen 2018-09-13 10:10:49 -05:00
parent 236eb14d59
commit c9d1be395d

View file

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