From 69b194302c80eb7eb7414b8aca083147342a0b4c Mon Sep 17 00:00:00 2001 From: Matt Hamilton Date: Tue, 5 Jan 2016 04:11:20 -0500 Subject: [PATCH] [prompt] add short_pwd func --- modules/prompt/functions/short_pwd | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 modules/prompt/functions/short_pwd diff --git a/modules/prompt/functions/short_pwd b/modules/prompt/functions/short_pwd new file mode 100644 index 0000000..dc93885 --- /dev/null +++ b/modules/prompt/functions/short_pwd @@ -0,0 +1,11 @@ +# 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}