Code like song
Here’s something else I’ve wanted to whip up for a long time. Mac’s pbcopy command is really handy, but I’d like it to accept arguments and treat them like cat or most other Unix commands: try to open each as a file and use its contents as input. I find myself writing something like “cat foo | pbcopy” a lot. Now I don’t have to:
#!/bin/sh
if [ -n "$1" ]; then
cat "$@" | /usr/bin/pbcopy
else
/usr/bin/pbcopy
fi
I’m not sure I’ve got the quoting right on the cat command, but it looks like it’s dinner time… .
UPDATE: No, the quoting was wrong. It’s fixed now.
I hope no one is upset about my “killing a cat”; that’s sort of the whole point.
blog comments powered by Disqus Prev: rtouch Next: First Draft of rtouch in Ruby