Shells

That alternative to GUIs by which you replace clicking-on-the-wrong-thing errors with typing-the-wrong-thing errors

October 3, 2014 — February 9, 2023

computers are awful
faster pussycat
Figure 1

The only thing worse than shell scripting is doing without shell scripting. Half a century on and we are still not great at bespoke automation of tasks. The best option is to have a grad student or an intern to do things for you; but what if you are the grad student or the intern?

Unix-esque (i.e. POSIX.2) shell scripting is one passable methods for automation of some tasks for those without underpaid human assistants. It is universally available, or at least nearly so, and indeed useful. Except the problem is that shell scripting is a ghastly quagmire of chaos, and, as usual, for the traditional variety of path-dependent reasons, the dominant players in the market have especially high chaos content in their quagmire.

“Shell” as I will lazily use it here may conflate several things, a scripting language, and a protocol for interacting with the system and displaying things on the screen (the “terminal”), and also the UI design for all the above. These all interact in complicated ways, especially on a modern system, but I’m going to brush over this nicety, because who cares?1

There is much soul-searching about how all this is conflated, dissected and implemented, and philosophical wars about it. See, perhaps, the oilshell overview for a list, which identifies many other categories and subtypes here. Notably they separate the POSIX comaptible shells (bash, zsh) from the others. The POSIX standard is useful to fulfil for compliance of various bits of system infrastructure, but does not lead to the most polished user experience so I will not mention it especially here.

1 Your list of horrible alternatives

There are many, many others than listed here, most of which only last a year or two before their maintainers give up and use bash. You too can roll your own vanity shell!

Idea: create shells cash, trash, theclash, and bangersandmash.

Alternatively: why does not someone implement Martin Sustrik’s extremely left field shell idea, hull, which stores all state in the file system and implements a stack through pushd?

1.1 bash

bash is the default for most humans who must sojourn in this grim dale of automation. It has the virtues of having decades of careful crafting, optimisation and of ubiquity, and the vice of having decades of bitrot, accommodation to ill-considered primordial design choices, and of occasionally uploading all your personal data to online gangsters. I cannot personally understand why it is a symbol for the Linux ecosystem, because I find it one of the more aggravating bits.

1.2 fish

fish has a strong fanbase and principled design. I now use it as my main shell and find it pleasing. It’s no fancier than it claims to be, which is to say, a belated evolution in an old ecosystem. It focuses efforts on being simple, discoverable and interactive rather than an all-singing, all-dancing programming language, of which there are already a great many. This is probably sufficient for my needs.

1.3 PowerShell

PowerShell sprang from Windows but now runs everywhere and is open source. It even looks good, although not quite good enough at the particular problems I need to solve for me to invest time in using it. All the pros seem to use it in a kind of scripting environment called ISE.

Unique selling point: rather than passing strings around between commands, PowerShell passes structured objects of various kinds. This makes it powerful for text data processing, since you don’t need to process mere text.

See Awesome PowerShell for some neat applications.

Post script: now Windows has bash too, and no one is safe.

1.4 nushell

nushell a shell with structured text data processing emphasis, much like powershell.

1.5 crush

crush is similar again to nushell but more of a solo passion project for some fellow called Axel.

1.6 dash

dash is a less bloated bash clone, which by itself doesn’t seem advantage enough to sell it widely.

1.7 zsh

zsh was a young turk of a shell, and may still be seen stomping about the internet, waving its walking cane while complaining about the benighted conservatism of that frightful old fart, bash.

1.8 cosh

1.9 oils

Reimplements most of bash but aims to Do It Right. I do not know how useful it is but it generates lots of good thinkpieces. I am unlikely to ever use this as a shell, but the thinkpieces are interesting.

Oil is a new Unix shell. It runs your existing shell scripts, and it’s a new language for Python and JavaScript users who avoid shell!

There are some suspiciously obstinate design decisions in the shell implementation.

1.10 xonsh

xonsh uses a hybrid of python and bash syntax and has light dependencies plus the python standard library, as well as some gentle mockery of the design choices in plumbum. (Tutorial)

Xonsh is a Python-powered, cross-platform, Unix-gazing shell language and command prompt. The language is a superset of Python 3.5+ with additional shell primitives that you are used to from Bash and IPython. It works on all major systems including Linux, Mac OSX, and Windows. Xonsh is meant for the daily use of experts and novices alike.

John D Cook interviewed the creator and there was some insightful background that came up about how all this stuff works.

See also the fork. tako, which is smaller and faster probably.

1.11 Plumbum

Plumbum brings a shell “feel” to python, and looks passionately maintained if not broadly used.

1.12 Elvish

Elvish is yet another shell with passionate following. Written in go. Looks clean. Aims to be a full programming language as well as a user interface.

1.13 neugram

neugram is … a shell for go? idk. TBC.

2 General tips

2.1 Switching shells

e.g. to fish

First you might need to bless the shell.

which fish | sudo tee -a /etc/shells

Then the trick is

chsh -s `which fish` `whoami`

2.2 Next-level piping

dgsh:

The directed graph shell, dgsh (pronounced /dæɡʃ/ — dagsh), provides an expressive way to construct sophisticated and efficient big data set and stream processing pipelines using existing Unix tools as well as custom-built components. It is a Unix-style shell (based on bash) allowing the specification of pipelines with non-linear non-uniform operations. These form a directed acyclic process graph, which is typically executed by multiple processor cores, thus increasing the operation’s processing throughput.

3 Realistically you’re using bash; now what?

Try out some actual commands.

Footnotes

  1. Answer: dedicated and wonderful developers from whose work I am grateful and humbled to benefit.↩︎