Hacker News new | ask | show | jobs
Sl: a steam locomotive in your terminal (aasen.in)
99 points by aaasen 4843 days ago
24 comments

On the Sun/Solaris machines where I first worked, the `sl` command had an added bonus: it played a really loud "choo-choo" sound from the workstation's internal speaker, regardless of volume or mute settings, so you always knew when someone fat-fingered their file listings, and much laughing was had by all.

I very quickly learned to alias sl=ls in my shell rc, and it's still in there to this day, just in case...

I highly recommend the debian bug tracker on `sl`:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=614158

Also, for those that love their cars "pre-tuned by german engineers", there is `gti`:

http://r-wos.org/hacks/gti

There are some nice closed bugs too. Here is an argument over whether it should support ^C by default: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=598992
Veteran: "You should apt-get install sl."

Newbie: "What does sl do?"

Veteran: (perfectly straight face) "It trains you."

Debian ships `alias sl="ls"` in the default .bashrc
Weird. My Debian systems don't have that alias...
I've always wondered: why is it a locomotive? Why not a penguin or something else?

Just thinking aloud here: ls stands for 'list'.... so sl stands for 'tsil'.... which is a model of a train? No, that's not it.

I think there's a missing part to this joke.

[edit] Just stepped away from my desk and took two steps and figured it out: sl = steam locomotive

Regarding the penguin: sl(1) was originally written in 1992; Linux itself didn't hit 1.0 until 1994, and the Linux penguin itself wasn't introduced until 1996.
sl, steam locomotive.
I added this to Homebrew years ago, for those OS X users.
I just installed it, thanks!

Also, brew seems to have added a beer mug emoji to the terminal output when it finishes installing something since the last time I installed anything. I didn't know the terminal (Actually iTerm 2 in this case) even supported that. Neat!

It is also in MacPorts
When a colleague accidentally types their password to our cluster into a chat window, the first thing I do is login as them and alias ls=sl. Another fun one is to add `telnet towel.blinkenlights.nl` to their .bashrc, so on login they get to watch ascii star wars.
... and if you unset telnet's escape char, they will watch it to the end.
That's hilariously evil
It warms my heart to see that towel.blinkenlights.nl is still up.
The one bad thing about switching to the Dvorak layout is that in Dvorak, ls is really cumbersome to type. The l isn't on the home-row, and both of them are on the right pinky. The way I do it now, it's virtually impossible to type sl instead of ls.

Typing dc instead of cd, though is still very common. And dc just mockingly tells me: "will not attempt to process directory."

(I now have `no` aliased to ls. Maybe I should alias `on` to sl.)

    > The following code changes the default behaviour of ls from listing
    > files to turning your terminal into an unstoppable steam locomotive.
    > The only way to end it is closing the terminal, so use this with caution.
erm, that's easily stopped:

    [ctrl]+z
    $ pkill -9 sl
^Z will just suspend `sl`, at which point bash will immediately launch another copy. That's what the loop is for.
Have you actually tried it? In neither zsh nor bash does this seem to actually be the case.
Well no, because I didn't want to install `sl`.

But it looks like you're right. I just tried `while true; do ( echo hi; sleep 1; echo bye; ); done` and ^Z does stop the cycle.

Interestingly, at least how I have zsh configured and don't have bash configured, the behavior of `fg` after suspending these is different.

With zsh when I resume the execution it continues looping. However with bash it resumes for only one more iteration.

Yeah I would have expected `fg` to continue the loop, but it doesn't. If I put `echo $?` after the subshell in that loop, it doesn't even print when I run `fg`. It's like bash just throws away the loop entirely when I suspend the subshell.
Bash wont immediately launch another copy because the PID is still alive (even if it is stopped).
erm, no? "while true; sl; done"
Hold ctrl + c down, eventually sl will have quit, and bash will quit the while loop. I've never had issues quitting out of

  while true; do echo "stuff"; done
for example.

   zsh: suspended  while true; do sl; done

?
erm, yes. I suggest you try it before commenting next time.
Bonus info:

if you add arguments to sl like -l or -a you get a different locomotive or other effects!

Why alias commands to sl? The point is for it to be triggered on bad typing.

Also, the man page is worth a look -- http://manpages.ubuntu.com/manpages/precise/man6/sl.6.html

The moving train uses js for motion. I stripped that part to http://jsbin.com/ujizup/1
I did a little video on this a couple of weeks a go with a mini how to for Fedora users https://news.ycombinator.com/item?id=4766611
first saw this thing around 12 years ago on an AS/400 terminal. Our neckbearded Lead Programmer was supposed to have programmed it in RPG but probably this thing is even older?
The source downloaded from the authors page[1] lists the following modification times:

    [ skade sl ] ls -la *
    -rw-r--r-- 1 skade staff  331 Jul 22  1998 Makefile
    -rw-r--r-- 1 skade staff  417 Jul 22  1998 README
    -rw-r--r-- 1 skade staff  689 Jan 18  1994 sl.1
    -rw-r--r-- 1 skade staff 7.0K Jul 22  1998 sl.c
    -rw-r--r-- 1 skade staff 4.1K Jan 18  1994 sl.h
    -rw-r--r-- 1 skade staff  980 Jan 18  1994 sl.txt
So, it is almost 20 years old.

[1] http://www.tkl.iis.u-tokyo.ac.jp/~toyoda/index_e.html

Great, excellent, fun.

But, clearly, it should run 'ls' after doing its choo choo?

That is optimizing for the short term. "When I've run sl, I clearly wanted ls, so you should give me that (even if you also punish me)."

Optimizing for the long term is also plausible. "Don't reward me for making mistakes (even if you also punish me) because it'll dilute my muscle-memory training, and I'll be more likely to make mistakes in the future."

Neither of these is inherently more correct than the other. The long term has more uncertainty, but greater potential rewards. We just have to make a judgment call.

I tend to favor the long-term approach for sl. I can't easily quantify how valuable my stricter muscle-memory training will be, but I can imagine the possibility of a significant upside if I actually become a more precise typer. Also, the worst-case downside just isn't that bad -- retyping ls just isn't that hard.

Well, this forces you to type 'ls' again, giving you another chance to see the awesome locomotive! ;)
The Unix philosophy is that a program should only do one thing. sl only does one thing.
One could use a shell alias, a function or something similar for that.
alias sl='sl;ls'
"Note: I actually didn't use a marquee for this. The one good use for one, and I missed it. Damn."

Is this even a good example for using html marquee?

How did you get this in the main repositories? I'm curious what the process is for something like that.
According to someone else's comment this thing is at least 20 years old. AFAIK these things go by popularity, after all any sort of game is also non-productive...
I just installed it on my Raspberry Pi. It's in the Raspian repository too!
If you're on a Mac with homebrew, "brew install sl" will get you there!
Not the same thing but "apt-get moo" on a Debian based box is fun...
Oh come on! This isn't news. I was using sl fifteen years ago.
alternatively if you are really evil, you can 'alias ls="rm -rf"'
We need one for "got"
Okay that is freaking awesome. I now have GoT's theme playing in the terminal.

This may actually make me misspell git even more.

Got,

Got Milk?, Displays Got Milk? Advert. Boring

GOThic, Changes terminal font to Gothic?

GoT, Game of Thrones, Decapitates user?, Automatically fires up BitTorrent client and grabs latest episode? Plays ASCII art GoT episode? Cat's all of GRRM's GoT novels into your terminal? (That'll teach you).

A shitogram for modern age.
had to apt-get sl
on os x - brew install sl brings it in.