
Sl: a mirror version of ls - fredrb
https://gir.st/blog/sl-alt.htm
======
_Marak_
Probably an unpopular opinion, but I find aliases and extensive dotfiles
counterproductive.

It's better to learn and remember the exact commands. If you find yourself
typing the same long command over and over again, the task should probably be
automated or scripted as part of a separate pipeline.

Assuming you are successful with aliasing and don't accidentally do something
unexpected and catastrophic to your system, the moment you login to another
system you will be lost and unable to remember any of the original and core
commands.

~~~
stochastic_monk
There are plenty of cases where it can be unproductive, but I find it very
helpful in some cases.

I find `alias gcr="git clone --recursive"` to be very productive for me. I
never forget what it stands for, it saves me time, and I never have to go
fetch all submodules if the repo uses them. `alias lt=ls -tor` is helpful, as
it shows me extra information about files in reverse sorted order, so that the
most recently modified files are at the bottom.

I don't run any risk of forgetting either of these because of their mnemonic
nature, and they're not something I can script.

~~~
aynsof
I was of the same opinion as the GP until I started using Terraform. Coming
from a sysadmin background, I was always told to use default tools 'because
one day you'll ssh into a random server and it won't have any of your fancy
tools and config'.

So I started using Terraform. A lot. Day in, day out, I would type terrafrom,
teraform, terrafomr. And I'm a good typist! But something about that word just
makes it hard to get out right. (I have a similar issue with
'infrastructure'.)

Finally replacing it with a 'tf' alias saved me a lot of frustration.

~~~
outworlder
This is actually supporting GP's argument.

Why do you have to "type" terraform? Are you running terraform from your own
machine? Don't. Setup a Jenkins pipeline or what have you. Unless you happen
to work alone – and I'd argue even then.

Moving Terraform to Jenkins was the second best thing we have ever done –
first thing was moving tfstate to remote storage.

You can provide any required parameters (or jenkins can fetch for you), run
terraform init, plan, ask for confirmation, apply (and even perform retries).
And then run any post steps. Even managers can use terraform now (and we have
a pretty complicated setup).

I guess only Terraform Enterprise might beat this, but I have little
experience with that.

~~~
aynsof
We ran Terraform in Bitbucket Pipelines builds - full testing with awspec,
remote state in S3, statefile locking in DynamoDB.

It might surprise you, but there are cases where you might not want to run
Terraform in a pipeline.

~~~
yebyen
What is this awspec? I would like to subscribe to your blog or mailing list!

:+100:

~~~
aynsof
Haha I don't have either, I'm afraid. Here's a link to the common
architectures I helped out on when I was at Geoscience Australia:
[https://bitbucket.org/account/user/geoscienceaustralia/proje...](https://bitbucket.org/account/user/geoscienceaustralia/projects/TF)

Here's a direct link to the awspec tests for one of the repositories:
[https://bitbucket.org/geoscienceaustralia/webserver/src/ab6f...](https://bitbucket.org/geoscienceaustralia/webserver/src/ab6fcfaa5926e6a2c9a15240ebefc082c47cefcf/tests/spec/?at=master)

------
pubby
I always liked the story about the guy who aliased emacs to be 'em'. Until one
day he accidentally typed an 'r' instead of an 'e'. It turns out aliases can
cost a lot more time than they can save!

~~~
sanbor
If he would just had an alias of rm to `rm -i`...

------
p3llin0r3
I like to add "install
[https://github.com/mtoyoda/sl"](https://github.com/mtoyoda/sl") to my
companies "Getting started" documentation to prank new hires. Great fun!

~~~
burnte
I was hoping someone posted this, if not I was going to. I installed it on one
of my home servers YEARS ago, and forgot about it until a couple years later I
typoed "sl" and it chooched across my screen. I howled with laughter at it,
and at setting myself up years in advance.

------
pantalaimon
Or you just

    
    
        alias sl=ls
    

and have productivity reach unseen levels!

~~~
simias
I've had "l" aliased to "ls -lhp" for so long that I can't work properly
without it. I think many distros also alias "ll" to "ls -l" by default (I
think CentOS/RHEL does it at least).

~~~
Symbiote
I have h=ls and hh=ls -l, which are much more comfortable with the Dvorak
keyboard layout. (The equivalent would be j and jj on Qwerty.)

~~~
zarex
Good idea. Dvorak users unite!

Do you use regular dvorak or programmer dvorak?

~~~
Symbiote
British Dvorak, since it keeps ", £, # etc where I expect them, but is still a
standard layout available on Linux and Mac.

------
iamdave
I once installed sl on a server. Completely forgot I put it there. It laid
there dormant for MONTHS without anyone tripping over it. Then....it happened.

"What the...why is my screen blac--is that a train-AW DAMMIT".

That person was me. The guy who installed the damn thing.

The progression from confusion, to curiosity, to realization that I had in
fact...just played myself was kind of amusing in the moment.

------
pronoiac
See also, gti: [http://r-wos.org/hacks/gti](http://r-wos.org/hacks/gti)

~~~
tobyhinloopen
As a golf owner, lol

------
mverwijs
No no no. There is only one 'sl'.

[https://asciinema.org/a/172723](https://asciinema.org/a/172723)

~~~
wewake
Thank you. You made my day! :D I'm confident that there are other such
commands that I'm unaware of and don't know how to find them. May be you could
help out.

------
WalterGR
Interesting.

Faced with the choice of _punishing_ myself for making a mistake vs. _adapting
my environment_ to accommodate me, I'll always choose the latter.

(Plus, since you use `ls` so frequently, just make `l` an alias of it,
especially if you have difficulty typing "ls"! Using a computer doesn't have
to be some weird, punishing, bondage and discipline experience.)

~~~
arbie
Agree. It's why I alias . to pwd and .. to go up a directory.

~~~
kbd
Here are some of what I use:

    
    
        alias   -- -='cd -'
        alias     ..='cd ..'
        alias    ...='cd ../..'
        alias   ....='cd ../../..'
        alias  .....='cd ../../../..'
        alias ......='cd ../../../../..'
        
        alias l=ls
        alias la='ls -a'
        alias ll='ls -l'
        alias lla='ls -la'

~~~
msoucy
I personally have a single function that takes care of all of those dotted
aliases:

    
    
        function up {
            local ups="."
            for((i=0;i<${1:-1};i++)); do
        		ups="${ups}/.."
        	done
        	cd "$ups"
        }

~~~
kbd
I appreciate the DRY-ness of it, but that requires you to type 'up ...' which
is longer :(

A while ago when I was bored I was thinking of golfing those aliases to say
(pseudocode):

    
    
        for i in 2..6:
          alias '.'*i=cd '../'*i
    

but I didn't know all the shell needed and just wound up leaving it as is.

Edit: turns out Zsh has a 'repeat' built-in:

    
    
        alias $(repeat 7 echo -n '.')="cd $(repeat 7 echo -n '../')"
    

Still, non-portable, less clear, not worth changing the aliases.

------
staz
Not to be confounded with the other project of the same name (and with the
same purpose) [https://github.com/mtoyoda/sl](https://github.com/mtoyoda/sl)

~~~
oneeyedpigeon
It's mentioned right in the very first paragraph of the article.

------
combatentropy
a beautiful web page, and its only CSS is this:

    
    
        body {
            max-width: 50em;
            margin: auto;
            padding: 1em;
            line-height: 1.5em;
        }
    
        pre {
            overflow-x: auto;
        }

~~~
oneeyedpigeon
Yeah, but that's some horrible use of the fieldset element ;)

------
tomxor
Maybe i'm just weird but I can't recall ever making this typo, I find myself
making letter-swap typos of words/commands with letters on the same hand often
enough but that's not quite so easy with ls.

~~~
jake-low
Maybe it’s your keyboard layout? I used to make this typo (ls -> sl) on
QWERTY, but I later switched to Dvorak where both L and S are typed with the
right pinky. I think it slowed me down enough on that keypair that it never
happens anymore.

------
gue5t
This code is incorrect: it has a a race condition that can cause it to use the
wrong maximum width in its listing.

~~~
joombaga
I'm not seeing it. Can you elaborate?

~~~
pcdavid
It invokes "ls" twice. There's no guarantee the maximum width obtained from
the first invocation is still correct for formatting the result of the second.

------
afranchuk
I don't want to sound high and mighty or anything, but I've never mistyped
'ls'. I occasionally mistype other short binaries/commands, but typically
anything more than ~4 characters has me hitting tab, and that usually
completes uniquely and (obviously) correctly.

~~~
fragmede
Then you're typing slower than you could.

By all means, type however you want to type, but if you _never_ __ever __make
a mistake, then you could push yourself harder.

~~~
afranchuk
Dunno about that. I type pretty fast (don't have exact numbers to back that
up, just other people's comments) But regardless of that, typing two
characters that are on opposite sides of the keyboard and each use a separate
hand is, for me, pretty much error free. I make mistakes when letters are
closer and using the same hand.

------
oblio
This should go the whole hog:
[https://ubuntuforums.org/archive/index.php/t-2078323.html](https://ubuntuforums.org/archive/index.php/t-2078323.html)

------
femto113
For some reason I don't get ls wrong (right handed so maybe I reliably hit the
l first) but I've had the following in my .alias for years

    
    
        # some common typos
        alias grpe grep
        alias gpre grep
        alias mroe more
        alias mreo more
        alias rmeo more

------
richardkiss
This didn't work on Mac OS due to "wc -L" so I whipped up a python version.

[https://gist.github.com/richardkiss/4fba0c6bd27eb39a9eb56074...](https://gist.github.com/richardkiss/4fba0c6bd27eb39a9eb56074dd0f2ba4)

------
amichal
Long ago there was a ms dos. program called “rude dos” that if installed would
replace the all commands with versions that randomly and rarely would refuse
to work with various rude messages. I always ran it before letting my little
brother use my computer :).

------
thecatspaw
> Consider this code GPLv3 licensed.

is this actually valid? Does it mean the code _is_ GPLv3 licensed or not?

~~~
simias
Create a closed source product based on the code and find out!

------
stochastic_monk
The `wc -L` call fails on my Mac, but if I substitute gwc (as I have GNU
coreutils available with a "g" prefix), it works.

------
richardkiss
This didn't work on Mac OS due to "wc -L" so I whipped up a python version.

------
gjvc
not quite there but

alias sl='/bin/ls -l | tac | rev | column -t'

~~~
dmix
I was thinking this could be a simple alias with an AWK script.

------
dexen
In similar vein: express your inner rage while terminating offending
processes.

[https://github.com/robotlolita/fuck-you](https://github.com/robotlolita/fuck-
you)

~~~
saagarjha
Killing one memory hogging processor with another!

------
sullyj3
I always alias "ls" to "l"

------
girst
Hi, author here. Feel free to ask questions!

