3 ms·
Erratum: the break test at the top of the loop body needs to go to the bottom: while true; do local status="$esc[7m$(date +%m-%d/%H:%M)$esc[m $HOSTNAME $
by kazinator 3y ago
Erratum: the break test at the top of the loop body needs to go to the bottom:
while true; do
local status="$esc[7m$(date +%m-%d/%H:%M)$esc[m $HOSTNAME $dots$pwd"
local status_len=$((${#status} - ${#status_esc}))
[ $status_len -le $COLUMNS ] && break
pwd=${pwd#/}
pwd=/${pwd#*/}
dots='...'
[ "${pwd#/*/}" == "$pwd" ] && break
done
This fixes an issue reported by a user on Mastodon: that when you change to a directory like / or /home, the status line disappears.