Vlad's Roam Garden

Powered by 🌱Roam Garden

use general-purpose language to augment your command line experience

command line is powerful abstraction. a lot of people are familiar with Unix tools - ls, find, grep, etc.

The problem for me personally comes up when I try to string these simple tools together or do some complex processing on their output (besides basic things like piping output to grep).

Which is kind of funny because the whole Unix philosophy is structured around highly specialized tools that are supposed to be easy to combine 😛

To properly connect things together - you need to either learn

bash - which is a pretty lousy language

more obscure options of the above commands, which while potentially powerful don't seem to have such a great ROI

If you're using the general-purpose language anyway - why can't you invoke native functionality ~equivalent to commands your'e calling out to?

don't know it/is often more cumbersome/requires specialized libraries

hence less suitable for ad-hoc tasks/automations

My solution to this problem is to use a general purpose language in an interactive console (IPython).

Ruby is my default go-to, though I'm experimenting with Kotlin as-well.

What makes Ruby particularly nice here is that:

It has a nice interface for running external commands by just putting them in "`". This provides a very low-friction way to execute a command, process it's output pass it over to another command.

It has pretty good transformation pipeline functionality. Which provides good abstractions for and further reduces friction for text processing

I recently discovered that I can do similar things in Kotlin. And, the nice thing about that is that I actually know Kotlin in contrast to Ruby, which I have a rather surface familiarity with. Leading me to having to constantly Google things like "how do I x in Ruby". Kotlin + some extension functions can be very cozy

caveat - examples to show general principle, can have better ways of solving things

execute commands in all packages of a workspace

`ls ..`.split
`ls ..`.split.each {|it| `cd ../#{it} && git fetch`}
`ls ..`.split.map{|it| `cd ../#{it} && git checkout -b test`}

`ls`.split.filter{|it| it.end_with? ".webp"}.each {|it| `dwebp #{it} -o #{it}.png`}` 
was really easy to write