Mon May 29, 2017

Huck Shell

Huck Shell

Formerly “ntla”, which stood for:

Never type ‘ls’ again

Never?  Well, rarely, anyway.


hucksh is a shell-as-web-app: a server runs on your computer, under your own user ID, like a regular shell, and runs commands. Instead of a tty, you interact with it via your browser. You can easily navigate your directory tree by point-and-click, and you can enter commands, which the server runs, and sends you the output over a websocket.

Will it do everything I talk about below? Well, not yet.  (In particular, it doesn’t do typed pipelines.)  But it can do a lot: navigate the file system, run commands, and edit files.

Background and rationale

Clickable trees

Have you ever gotten tired of

% cd dir1
% ls
% cd dir2
% ls
% cd dir3
% ls
% ...

? I looked at my shell history and found that over 90% of the commands I ran were “cd” and some variant of “ls”.  A very basic Apache configuration will give you a navigable view of your directory tree, and it turns out http.ServeFile will do the same.


ttys are 1970’s technology. Wouldn’t it be nice to be able to do something a little more modern? Like, say, style your directory listing with CSS instead of escape codes?

Running commands

And what is a shell, really? At its core, you give it a command and some arguments, and it runs the command. There’s a little more to it than that — like pipelines, and a scripting language — but that’s the core of it.

Pipelines and parsing

Speaking of pipelines, I got tired of ad-hoc parsing of what should have been structured, typed streams.  grep, for example, should output a stream of records with fields for the filename, the line, the expression matched, the match position, the text matched, and so forth.  Similarly for ls, du, df, and other commands that output structured data.

Edit locally, save remotely

I usually work over a VPN (two of them, in fact).  The lag is usually small, but can sometimes be irksome.  Sometimes when travelling I have to proxy over my phone, and so pay per byte.  I’ve cobbled together a workflow that works (rsync for the win), but seems suboptimal.  How about if the server sends me the file, I edit it locally, and only have to talk to the server to save the file again?  (Though admittedly, I send the whole file back again; I haven’t reimplemented rsync in Javascript.)

CodeMirror: a clean, hackable, well-documented editor API

And finally, the browser-based editors are getting pretty snazzy. I love Vim, really, I do, but Vim Script leaves something to be desired, Vim internals are fairly hairy (in my opinion; if you like them, that’s fine :), and frankly I’d just rather hack on CodeMirror in Javascript than Vim in C or Vim Script.

Demo video, a whirlwind tour

Other features

hucksh has some other features, some not found in any other shell anywhere, so far as I know.

  • All output is saved permanently in a sqlite3 database.  You can see what you ran yesterday, or a year ago, even across page refreshes, browser restarts, server restarts, or complete reboots.  It’s sort of like “screen”, except more persistent.
  • Output data with delimited text (“a,b:c,d|e|f,g,…”) can be turned into a table at the press of a key.  The delimiter(s) used can be modified interactively per-command.
  • Output data can be edited in-place.
  • Output data of a previous command can be manipulated in Javascript by a later command.
  • The start time, stop time, duration, and $PWD of all commands are logged.  You can easily cd back to the $PWD of a previous command by just clicking it.
  • Commands can easily be run again, in the same directory as before, by clicking the “run again” button.
  • The directory browser can be sorted in-place by any column (size, time, name, etc).
  • You can easily run Javascript by using j{}, or even more easily by starting with a leading =.  This makes for easy math at the command line, e.g. =1+3 => prints 4.
  • You can easily run Go by using g{}.  This calls “gore” to actually run the code.  See the doc on Github for details.
  • The server can do TLS (https) or non-TLS (plain http).
  • Each command has its own separate output panels for stdout and stderr.  Output and error are not interleaved for a single command, or with other commands.  Among other things, this means you can follow (“tail -f“) two different files and the output won’t overlap (if you run the two tails as two separate commands, of course) .
  • Click on a file in the file browser and it opens in a local editor tab.  You can edit and save, but not yet much else.

Some misfeatures / problems / known bugs

  • Neither Javascript commands nor their output are stored on the server in the persistent database.
  • There are still some problems to be ironed out when a command outputs copious amounts of data.  The client can hang trying to keep up.
  • If you have a command running in one tab, and you open a new tab, the new tab will not be updated when the command finishes.  Once it finishes in the first tab, you can reload the 2nd tab.
  • Nothing is as configurable or polished or good-looking or finished as it should be.  I’ve focused on adding functionality; making everything polished and pretty has taken a bit of a back seat.
  • Sending input to a running command is still fairly rudimentary.
  • Configuring TLS is not yet very well documented.  For that matter, neither is anything else.
  • Running hucksh facing the Internet on a public port, even using TLS, is not yet recommended.  I’ve done my best to implement hucksh in a safe and secure manner, but for now I recommend keeping it inside the firewall.  After all, if I’m wrong, then an attacker gets shell access.
  • The hucksh web client runs poorly on mobile platforms.

I would like to fix all of these things, but do still have to prioritize.  Huck Ridge Software is not my day job.

Install and run

The server is designed to run as a regular user process, listening on a regular unprivileged port (18022, by default).  It needs no special privileges to install or run.  It runs under your own ID and thus can do anything and everything you could do with a regular ssh session.  (That’s kind of the point, after all!)

(Download link coming soon.)

Installation and usage instructions

Help screen

Press the ‘?’ key to get a list of hotkeys.  (Make sure the command input pane is not focused, or you’ll just get a ? in your current command.)

Support, bugs, legal, etc.

Drop me an email at hucksh (at) huckridge (dot) com, or drop in on the hucksh support forum.

Read the EULA.