1
0
mirror of https://github.com/meineerde/dotfiles.git synced 2026-02-06 00:53:23 +00:00

Update calculation of short_pwd to also work on Bash 4

This commit is contained in:
Holger Just 2018-08-15 23:15:43 +02:00
parent fc2d6187d6
commit f6b528e424

View File

@ -186,7 +186,12 @@ PS1="${debian_chroot:+($debian_chroot)}"
# Short PWD, if it's to long.
short_pwd() {
FIXED_PWD="${PWD/#$HOME/~}"
local FIXED_PWD=${PWD#$HOME}
if [ ${#FIXED_PWD} -le ${#PWD} ]; then
FIXED_PWD="~${FIXED_PWD}"
else
FIXED_PWD="${PWD}"
fi
if [[ ${#FIXED_PWD} -gt $PWD_LENGTH ]]; then
echo "${FIXED_PWD:0:$((4))}...${FIXED_PWD:$((${#PWD}-$PWD_LENGTH+7)):$(($PWD_LENGTH-7))}"
else