Skip to content

Instantly share code, notes, and snippets.

@ernstki
Last active December 3, 2019 03:39
Show Gist options
  • Save ernstki/c78a3fc260acd96aa40980d5c8042ef6 to your computer and use it in GitHub Desktop.
Save ernstki/c78a3fc260acd96aa40980d5c8042ef6 to your computer and use it in GitHub Desktop.
A+ - like 'cat -A' with Unicode symbols
#!/bin/bash
# h/t: https://unix.stackexchange.com/a/196783/278323
#
# Unicode characters
# ⇥ (rightwards arrow to bar)
# https://www.fileformat.info/info/unicode/char/21e5/index.htm
#
# · (middle dot)
# https://www.fileformat.info/info/unicode/char/00b7/index.htm
#
# ↲ (downwards arrow with tip leftwards)
# https://www.fileformat.info/info/unicode/char/21b2/index.htm
#
# ␣ (open box)
# https://www.fileformat.info/info/unicode/char/2423/index.htm
TAB=$(echo -e '\u21e5 ')
NL=$(echo -e '\u21b2')
SPACE=$(echo -e '\u00b7')
# uncomment this to use open box instead of middle dot
#SPACE=$(echo -e '\u2423')
sed "s/ /$SPACE/g; s/\t/$TAB/g; s/\(.*\)$/\1$NL/" ${1:+"$@"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment