One-line program to sort clipboard

I often need to sort lines of text in a text document or spreadsheet, so I’ll select and ^C, then go to the command line and do:

echo "...^V to paste..." | sort | pbcopy -

It’s silly to keep retyping that – it ought to be consolidated into something short and sweet. So I created this one-line shell script and linked it to /usr/local/bin/pbsort:

pbpaste | sort | pbcopy -

To use it, ^C text in a document, go to the command line, type “pbsort”, return to the document, ^V.

Leave a Reply

Your email address will not be published. Required fields are marked *