Here’s a speed up for posting code in a <pre> or <code> tag in an html page or blog. The script escapes all less than and greater than symbols (< with < and > with >) in a given file then puts the results in the clipboard to facilitate pasting into a text area or text editor. Save this in a file called
#!/bin/bash cat "$1" | sed s/\</\\\<\;/g | sed s/\>/\\\>\;/g | pbcopy
Posting the above code was super easy now, I just ran
./escape-copy.sh escape-copy.sh and pasted it in a <pre> tag.