Skip to content

Instantly share code, notes, and snippets.

@tiagoad
Created January 13, 2025 13:24
Show Gist options
  • Save tiagoad/d3a8811b4e6a0977cfc004923a67aeac to your computer and use it in GitHub Desktop.
Save tiagoad/d3a8811b4e6a0977cfc004923a67aeac to your computer and use it in GitHub Desktop.
Script/command to replace non-printable characters with a placeholder in the format used by Sublime Text

Example:

Screenshot 2025-01-13 at 13 18 51

Add to .bashrc/.zshrc as an alias:

alias nonprint='perl -pe "use Term::ANSIColor; s/([^[:print:]\n])/colored(sprintf(\"<0x%02x>\", ord($1)), magenta)/ge"'

Use it as a script:

cat << EOF > ~/bin/nonprint && chmod +x ~/bin/nonprint 
#!/usr/bin/env perl -p
use Term::ANSIColor;
s/([^[:print:]\n])/colored(sprintf("<0x%02x>", ord()), magenta)/ge
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment