
One-liner to sort clipboard - lucasgonze
http://some.gonze.com/2016/08/22/pbsort/
======
jepler
On X-based systems, xsel -ob | sort | xsel -ib

But if you're in a high-octane development environment like vi, there's no
need to resort to a separate terminal window to invoke 'sort clipboard'. just
mark a range of lines (v) then :!sort to filter through good old unix sort.

~~~
jepler
Iterating on this idea just a little bit, you realize you want to apply _any_
shell filter to your clipboard ...

    
    
        #!/bin/sh
        # save as xfilt
        xsel -ob | "$@" | xsel -ib
    

so, for instance, get a bit of json in your clipboard
[http://json.org/example.html](http://json.org/example.html) and run xfilt jq
.glossary.title. Now your clipboard contains "example glossary" instead of the
whole json file.

One wrinkle is, if you get your filter wrong, you have to return to the
original source to copy again, because the operation is destructive each
time...

------
lucasgonze
This is a trivial but super useful hack. The way you use it is:

1\. You're in an edit field in any old app - browser, Atom, vi

2\. Select lines to sort and ^c

3\. alt+tab to command line

4\. pbsort

5\. alt+tab back to app

6\. ^v

