Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the '10.6: Format text via a Service and emacs' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.6: Format text via a Service and emacs
Authored by: 1amzave on Oct 28, '09 08:58:58AM
tmp=/tmp/emacsmail`date "+%s"`.txt
...would probably be cleaner via mktemp (1), and for this:
cat /dev/stdin | tr '\r' '\n' > $tmp
cat (1) reads stdin by default, so 'cat /dev/stdin' is redundant, though tr (1) also reads stdin by default, so the 'cat' is not actually needed (though if your system has it, 'mac2unix' may also be a slightly clearer way of achieving the same thing as that particular invocation of tr). In combination with fmt (1) as mentioned above, there should actually be no need for temporary file at all, obviating the 'mktemp' as well, and the script basically becomes a one-liner, perhaps just piping mac2unix into fmt (and maybe back into unix2mac again if you want carriage returns instead of line feeds).

I think the more fundamental hint here though is the mechanism of having text-manipulation scripts available as a service (and as mentioned, possibly with a quick hotkey) which is a cool idea that could allow lots of similarly-handy things.

[ Reply to This | # ]