Shell prompt that spans console width

I’ve been using this trick in my shell prompt for some time, which allows it to stretch and fill the width of the terminal window:

if [[ "$TERM" == xterm* ]]; then
    export PS1='\[\e[0;36m\n`/usr/bin/printf %${COLUMNS}s "+jobs:\j+    +\l+" | /usr/bin/tr " +" "- "`\r\u@\H:\[\e[0;32m\]\w\[ \]\n\[\e[1;33m\]  \$ \[\e[0m\]'
fi
comments powered by Disqus