Edit the Clipboard
I recently wanted to write some code in a Github issue, but while Github Flavored Markdown supports code snippets, the web editor has a variable spaced font that makes writing formatted code difficult.
vipe is a tool from moreutils that allows you insert an editor into a unix pipe.
vipe will create a temporary file with anything passed from standard input (empty if invoked directly) and open
$EDITOR on that file.
Anything that saved in that file when the editor closes is piped to standard output.
To solve my Github problem, I realized that I could invoke:
$ vipe | xclip -selection clipboard
which let me type my code snippet in my editor of choice, then copied that snippet onto my clipboard.
xclip -out can be used to output the current state of the clipboard, so:
$ xclip -out | vipe | xclip -selection clipboard
can be used to modify the current clipboard in an editor.