Shell Prompt Line Wrapping Issue Shell Prompt Line Wrapping Issue bash bash

Shell Prompt Line Wrapping Issue


I am now using this PS1 with good effect:

green=$(tput setaf 2)blue=$(tput setaf 4)bold=$(tput bold)reset=$(tput sgr0)PS1="\[$green$bold\]\h\[$reset\]:\[$blue$bold\]\w\[$reset\]\$ "

Scrolling through my command history appears to handle line wraps now. However in the meantime since this question was asked I have also updated my OS X to 10.6.3


This stackoverflow thread seems relevant. As someone noted in that thread, the Bash FAQ at mywiki.wooledge.org discusses how to properly quote color codes in Bash prompts (FAQ 53), and the proper invocation of terminal colors (FAQ 37).


Line wrapping issues in Bash are nothing new. Your PS1 should work as is but there is a bug in Bash 3.2.49. Consult the mailing list, there's yet another bug regarding this which was confirmed to be fixed in 4.0.

You can't do much more than tagging unprintable characters with \[ and \], the rest must be done by the prompting code.