str: a better tr command

4 views
Skip to first unread message

elzr

unread,
Oct 6, 2007, 4:47:50 AM10/6/07
to YubNub
The tr command has always been a blessing and yet I've always found it
bothersome. Not only do I always get confused with direction (is it
"1st word TO, 2nd word FROM" or the reverse?), I just hate having to
decide every single time. Worst, it wreaks havoc with my habits: after
a long time translating in the same direction my fingers learn it and
next time I want the opposite direction it takes several annoying
tries to unlearn the habit.

So I came up with str ("super/simple/synchronous tr"), which avoids
the direction decision by doing both at once, each one presented in an
individual vertical frame. This is not only much faster in practice,
it's more unconscious and habit-friendly. Remember, thought is
irksome!

Cheers!

Jonathan Aquino

unread,
Oct 6, 2007, 8:04:03 PM10/6/07
to Yub...@googlegroups.com
Beautiful idea and execution, elzr! You must be a student of Raskin/Cooper.

Jon

elzr

unread,
Oct 7, 2007, 4:50:09 AM10/7/07
to YubNub
Heh, you got me there, I'm a Raskin fan. Cooper has been under my
radar for a long while but I've never read him. Is he good?

On Oct 6, 7:04 pm, "Jonathan Aquino" <jonathan.aqu...@gmail.com>
wrote:

Jonathan Aquino

unread,
Oct 7, 2007, 1:12:33 PM10/7/07
to Yub...@googlegroups.com
I enjoyed his About Face. Some are turned off by his opinionated style; I
didn't mind it.

Another opinionated book I am currently enjoying (about English grammar) :
The Elements of Style, by Strunk and White.

elzr

unread,
Oct 8, 2007, 3:38:32 AM10/8/07
to YubNub
Ah, Strunk & White--"vigor is a by-product of brevity." Great book.

I've found opinionated-ness, when clearly stated as so, to be actually
a mark of good writing. The Economist, for instance, introduces its
opinions with a classy "this newspaper believes".

Bad writers muddy the waters, good ones state clearly what is fact and
what is their opinion. Every writer has opinions on what she's writing
(otherwise, why write?). Being clear about them is just one more way
to be objective.

So let's give About Face a try. :)

On Oct 7, 12:12 pm, "Jonathan Aquino" <jonathan.aqu...@gmail.com>

Jonathan Aquino

unread,
Oct 20, 2007, 9:35:58 PM10/20/07
to Yub...@googlegroups.com
Here's a neat command: switch

Example: switch tree | sky => blue, tree => green, sun => orange
Returns: green

If the key cannot be found, the last option is returned.

Example: switch rock | sky => blue, tree => green, sun => orange
Returns: orange

Jon

Brian

unread,
Oct 21, 2007, 4:54:24 PM10/21/07
to YubNub
That's a good command, Jon. Thanks!

It reminds me of this old discussion we had about boolean switches:
http://groups.google.com/group/YubNub/browse_thread/thread/fadfc4878349ec4c/0d94d99e3b769df1

On Oct 20, 8:35 pm, "Jonathan Aquino" <jonathan.aqu...@gmail.com>
wrote:

Brian

unread,
Oct 21, 2007, 6:38:13 PM10/21/07
to YubNub
I created a command "searchswitchtest" to test it out:

yubnub {switch {% 1 %s} | g => {url g {% 2- %s}}, y => {url y {% 2-
%s}}}

My command isn't very useful, but it's cool to see how "switch" could
be put to use.


On Oct 20, 8:35 pm, "Jonathan Aquino" <jonathan.aqu...@gmail.com>
wrote:

Jonathan Aquino

unread,
Oct 21, 2007, 7:00:54 PM10/21/07
to Yub...@googlegroups.com
Cool!

-----Original Message-----
From: Yub...@googlegroups.com [mailto:Yub...@googlegroups.com] On Behalf Of

Klink C

unread,
Oct 26, 2007, 10:29:45 AM10/26/07
to YubNub
I think I understand this now- It's much easier than continually
piping IfThen commands like I tried.

On Oct 20, 9:35 pm, "Jonathan Aquino" <jonathan.aqu...@gmail.com>
wrote:

Reply all
Reply to author
Forward
0 new messages