Visible whitespace in the shell

By Filip Salomonsson; published on May 23, 2008. Tags: bash unicode

Bash alias of the day. Stuff this into your ~/.bashrc:

alias visws="sed -e 's/ /\o033[37m\xc2\xb7\o033[0m/g' \
                 -e 's/\t/\o033[37m \xe2\x86\x92  \o033[0m/g' \
                 -e 's/\r/\o033[37m\xe2\x86\xb5\o033[0m/g'"

Then pipe anything to visws, and you'll get spaces, tabs and carriage returns shown in grey as sweet unicode characters (which my django-driven blog cannot show you, embarrasingly). Dots and arrows, basically.

(This will only work if your terminal encoding is utf-8. But it is, right?)

Update: To be clear, the "cannot show you" part is my fault, not django's.

Bonus: Here it is in action.

Screenshot of visws