[prompt] fix gitster path to reflect git repo
allow optional parameter for short_pwd Closes #41
This commit is contained in:
parent
080852c490
commit
fcc4c573a8
2 changed files with 6 additions and 12 deletions
|
@ -1,8 +1,10 @@
|
|||
# shortens the pwd for use in prompt
|
||||
|
||||
local current_dir="${PWD/#${HOME}/~}"
|
||||
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}//\%/%%}"
|
||||
|
|
|
@ -8,17 +8,9 @@ gst_get_status() {
|
|||
}
|
||||
|
||||
gst_get_pwd() {
|
||||
git_root=${PWD}
|
||||
while [[ ${git_root} != / && ! -e ${git_root}/.git ]]; do
|
||||
git_root=${git_root:h}
|
||||
done
|
||||
if [[ ${git_root} = / ]]; then
|
||||
unset git_root
|
||||
prompt_short_dir="$(short_pwd)"
|
||||
else
|
||||
parent=${git_root%\/*}
|
||||
prompt_short_dir=${"$(short_pwd)"#${parent}/}
|
||||
fi
|
||||
prompt_short_dir="$(short_pwd)"
|
||||
git_root="$(command git rev-parse --show-toplevel 2> /dev/null)" && \
|
||||
prompt_short_dir="${prompt_short_dir#${$(short_pwd $git_root):h}/}"
|
||||
print ${prompt_short_dir}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue