The first result I get in Google when trying to set Bash's PS1 to use colors seems to be wrong (or, rather, I wasn't smart enough to make it work). An escape sequence seems to be missing, resulting in weird behavior with new lines; colors work, but line wrapping gets broken. Took me a while to associate broken \n's with colors, but once I did the fix was easy. Check out here for the proper way to escape color commands in Bash: https://stackoverflow.com/questions/342093/ps1-line-wrapping-with-colours-problem
And here's my current setup:
export COLOR_SET='\[\e['$THIS_HOST_COLOR'm\]'
export COLOR_RESET='\[\e[0m\]'
# Example:
export PS1='\A '$COLOR_SET'\h'$COLOR_RESET':\w$ '
No comments:
Post a Comment