echo shore/samhunter/blog/2026/09/20.txt | nc nightfall.city 1900 | less
## 2026.09.20 / Sunday

## Unix (shell) is my IDE, pt. 1

I'm lazy AF. The perspective of doing the same thing today, and
tomorrow, and overmorrow, and in two weeks... (you catch the
drift) fills me with dread. Or typing the same averagely
interesting shit over and over again. My .bash_history is set to
100k lines, before the oldest entries fall off the bottom.
Sometimes my laziness even keeps me from opening an editor and
writing a few lines of code. Because -- why would I have to, when
Unix shell lets me solve it with a few commands chained with
pipes?

### Prototyping in Bash

It's already running. No need to start anything, it's "always
there", when I open a new terminal window or a new window in tmux.
It's also quite probably I'm going to do something before and
after I run my piece of code. Why to click around like a monkey on
PCP?

I'll just type it where I already am...

$ printf "/shore/\r\n" | nc nightfall.city 1900

oh well, I can add a timeout, just in case. Up arrow fetches the
previous line from the shell history...

$ printf "/shore/\r\n" | nc -w5 nightfall.city 1900

Still works. It's a lot of typing, though

$ get_nex() { printf "/shore/\r\n" | nc -w5 nightfall.city 1900; }
$ get_nex

Still works. But only for one location.

$ get_nex() { printf "%s\r\n" "$*" | nc -w5 nightfall.city 1900; }
$ get_nex /shore/garden

Still works. Now I can save it, either to my profile:

$ typeset -f get_nex >> ~/.bashrc

or into a separate file:

$ echo '#! /usr/bin/env bash' > ~/.local/bin/get_nex.sh
$ typeset -f get_nex >> !$
$ echo 'get_nex "$*"' >> !$
$ chmod +x !$
$ get_nex /nex

Still works...


1. I lied about not using an editor. Bash's readline IS a
microscopic, but pretty usable subset of emacs (in its default
setting)
2. It doesn't have to be a oneliner. It is possible to write
bigger programs (a script is a program), although a good rule of
thumb says - if you're crossing the 100 lines limit -- better
switch to a "real" programming language like Python or whatever is
the tool of the day.
3. Sometimes a prototype becomes the tool. Shell isn't the fastest
interpreter around, but sometimes it really doesn't matter. Use
your common sense, don't follow the dogmas.
4. _Always_ use a shebang line. The future you will thank you,
when the account you're on doesn't use Bash as it's default shell.