Always show complete current dir when shortening path

When LP_PATH_KEEP=0 and current dirname were over maximum length the
name was also shorten. With this fixed _lp_shorten_path should now
always return at least the complete current dirname.
This commit is contained in:
polyphemus 2013-12-01 12:52:34 +01:00 committed by Olivier Mengué
parent 467490f20f
commit 81c4ff1c05

View File

@ -542,7 +542,9 @@ _lp_shorten_path()
ret="${p}"
elif [[ ${LP_PATH_KEEP} == 0 ]]; then
# len is over max len, show as much of the tail as is allowed
ret="${mask}${p:${#p} - ${max_len} + ${#mask}}"
local ret="${p##*/}" # show at least complete current directory
p="${p:0:${#p} - ${#ret}}"
ret="${mask}${p:${#p} - (${max_len} - ${#ret} - ${#mask})}${ret}"
else
# len is over max len, show at least LP_PATH_KEEP leading dirs and
# current directory