mirror of https://gitlab.com/ceda_ei/wish
[Feature] Do not add text to PS1 if it is too wide.
This commit is contained in:
parent
3f156fdd35
commit
97fe2dbcc6
7
wish.sh
7
wish.sh
|
@ -76,10 +76,13 @@ function wish_append_left() {
|
||||||
if [[ $text == "\n" ]]; then
|
if [[ $text == "\n" ]]; then
|
||||||
((WISH_LPLINE++))
|
((WISH_LPLINE++))
|
||||||
WISH_LPL=(${WISH_LPL[@]} 0)
|
WISH_LPL=(${WISH_LPL[@]} 0)
|
||||||
|
WISH_LEFT_PS1="$WISH_LEFT_PS1$colors$text"
|
||||||
else
|
else
|
||||||
|
if [[ $((${WISH_LPL[$WISH_LPLINE]} + ${#text})) -lt $COLUMNS ]]; then
|
||||||
|
WISH_LEFT_PS1="$WISH_LEFT_PS1$colors$text"
|
||||||
WISH_LPL[$WISH_LPLINE]=$((${WISH_LPL[$WISH_LPLINE]} + ${#text}))
|
WISH_LPL[$WISH_LPLINE]=$((${WISH_LPL[$WISH_LPLINE]} + ${#text}))
|
||||||
fi
|
fi
|
||||||
WISH_LEFT_PS1="$WISH_LEFT_PS1$colors$text"
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# INTERNAL USE ONLY! Do not use this in plugins.
|
# INTERNAL USE ONLY! Do not use this in plugins.
|
||||||
|
@ -91,7 +94,7 @@ function wish_append_right() {
|
||||||
((WISH_RPLINE++))
|
((WISH_RPLINE++))
|
||||||
WISH_RIGHT_PS1=("${WISH_RIGHT_PS1[@]}" "")
|
WISH_RIGHT_PS1=("${WISH_RIGHT_PS1[@]}" "")
|
||||||
WISH_RPL=(${WISH_RPL[@]} 0)
|
WISH_RPL=(${WISH_RPL[@]} 0)
|
||||||
else
|
elif [[ $((${WISH_LPL[$WISH_RPLINE]} + ${WISH_RPL[$WISH_RPLINE]} + ${#text})) -lt $COLUMNS ]]; then
|
||||||
WISH_RIGHT_PS1[$WISH_RPLINE]="${WISH_RIGHT_PS1[$WISH_RPLINE]}$colors$text"
|
WISH_RIGHT_PS1[$WISH_RPLINE]="${WISH_RIGHT_PS1[$WISH_RPLINE]}$colors$text"
|
||||||
WISH_RPL[$WISH_RPLINE]=$((${WISH_RPL[$WISH_RPLINE]} + ${#text}))
|
WISH_RPL[$WISH_RPLINE]=$((${WISH_RPL[$WISH_RPLINE]} + ${#text}))
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue