On my day-to-day software engineering tasks, I sometimes have the need to pass the file or selection through another program and replace it with the output. The uncomfortable workflow on my Mac is:
- Select text and copy (
Open a terminal and type:
$ pbpaste | some_command | pbcopy
Go back to my editor and paste (
Lately, I’ve been doing that workflow more often. It was starting to become annoying. Vim and Emacs have long had support for manipulating the current buffer in this way. There is a package that does just that for Atom, my editor choice: The aptly-named pipe.
Select text to pipe into external commands and replace it with the output. Sort of like ! in vim. Commands are sent to your $SHELL.
Assuming I have a selection like:
1 2 3 4 5 6 7 8 9 10 11
I can select it, run
command-;) and type
pg_format at the prompt. The selection now becomes:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Writing Ruby Documentation or Examples
When creating blog posts, pull request or other code examples, I often use the fantastic
xmpfilter – part of the
1 2 3 4 5 6
After piping to
1 2 3 4 5 6
pipe package opens up a world of possibility for working with your current buffer and all the CLI tools that already exist. Give it a try.