Merge pull request #68 from ldidry/issue63
Fixed #63 -- Better fix, and fixed a path repetition problem.
This commit is contained in:
commit
8affd96f6b
15
liquidprompt
15
liquidprompt
@ -385,9 +385,8 @@ _lp_proxy()
|
||||
# + keep some left part of the path if asked
|
||||
_lp_shorten_path()
|
||||
{
|
||||
local p=$(echo "$1" | sed -e "s|$HOME|~|")
|
||||
if [[ "$LP_ENABLE_SHORTEN_PATH" != 1 ]] ; then
|
||||
echo "$p"
|
||||
echo "$1"
|
||||
return
|
||||
fi
|
||||
# the character that will replace the part of the path that is masked
|
||||
@ -400,6 +399,12 @@ _lp_shorten_path()
|
||||
|
||||
local len_percent=$2
|
||||
|
||||
local p
|
||||
if [[ "$_LP_WORKING_SHELL" == "bash" ]]; then
|
||||
p=$(echo "$1" | sed -e "s|$HOME|~|")
|
||||
elif [[ "$_LP_WORKING_SHELL" == "zsh" ]]; then
|
||||
p=$1
|
||||
fi
|
||||
local len="${#p}"
|
||||
|
||||
local max_len=$((${COLUMNS:-80}*$len_percent/100))
|
||||
@ -967,7 +972,11 @@ _lp_set_prompt()
|
||||
LP_USER=$(_lp_user)
|
||||
# LP_HOST is a global set at load time
|
||||
LP_PERM=$(_lp_permissions_color)
|
||||
LP_PWD=$(_lp_shorten_path "$PWD" $LP_PATH_LENGTH)
|
||||
if [[ "$_LP_WORKING_SHELL" == "bash" ]]; then
|
||||
LP_PWD=$(_lp_shorten_path "$PWD" $LP_PATH_LENGTH)
|
||||
elif [[ "$_LP_WORKING_SHELL" == "zsh" ]]; then
|
||||
LP_PWD=$(_lp_shorten_path "$(print -P "%~")" $LP_PATH_LENGTH)
|
||||
fi
|
||||
LP_PROXY="${LP_COLOR_PROXY}$(_lp_proxy)${NO_COL}"
|
||||
|
||||
# right of main prompt: space at left
|
||||
|
Loading…
Reference in New Issue
Block a user