Hacker News new | ask | show | jobs
SL(1): Cure your bad habit of mistyping (github.com)
107 points by lukestateson 1442 days ago
25 comments

After you think you are perfect, then there’s suicide linux: https://github.com/tiagoad/suicide-linux

“Any time - any time - you type any remotely incorrect command, the interpreter creatively resolves it into rm -rf / and wipes your hard drive.”

Up the stakes and mount your home NAS
This could be neat for production environments in a kind of chaos monkey sense
Leaves it a little difficult to tell which bed was shat.
Not if you log all terminal input to the production log server.
This is the new North Star for my system architecture. Another win for DevOps! Thank you.
Embrace your habit of mistyping: https://github.com/nvbn/thefuck#readme
I use that all the time as a shortcut to push new git branches without having to type the whole name.
In addition to tab complete for branch names, git has a `help.autoCorrect` config item that allows git to automatically correct typos in command names. I weirdly type "git poush" incredibly often, and it's nice for git to pretend I typed "push".
You can enable tab complete for Git including for branch names.

I don't know how I would live without that. I tend to make rather verbose branch names and typing it all out stuff like push would take forever.

Though, you have a much more fun solution.

`git push -u origin HEAD` pushes the current branch to `origin` with the same name you have locally. You could even add an alias for that.
Or set `push.default` to `current` to have plain `git push origin` push to the same remote name, ignoring the configured upstream (you might also want to set `remote.pushDefault` alongside that).
I have this in my `.zshrc` on my personal machine. I get a kick out of it:

```

function command_not_found_handler() { figlet "lol, $1" }

```

(I think the bash equivalent is `command_not_found_handle`).

This overrides the function that usually prints the `zsh: command not found: foo` message, and instead, mocks you, by printing "lol, foo" (but in big ol' figlet letters).

SL is in a similar, but admittedly much more elaborate, spirit.

I've been using prezto[0] for a long time so I'm not sure anymore if this is integrated in zsh, but at least using prezto I get this when I run a wrong command:

  > claer
  zsh: correct 'claer' to 'clear' [nyae]? n
  zsh: command not found: claer
I am guilty of not reading the docs, but I learnt by experience that n/y/a/e stands for no (run without correction)/yes (correct)/abort (don't run)/edit (manually/interactively)

[0] https://github.com/sorin-ionescu/prezto

SL(1): Learn the muscle-memory to send SIGQUIT all the time

Part of this tool’s “charm” is that it traps SIGINT so you truly are forced to watch the animation as a punishment for bad typing, even if you try to send it SIGINT from your keyboard by typing control-C.

Control-backslash sends SIGQUIT on the other hand. This signal cannot be trapped.

Perhaps sl could launch a parent process and a child process, put the child in a different process group, then restart the child if the parent sees it do a core dump?

Or launch two children — one of them daemonized — where the daemon attaches a new sl to your terminal if it sees its sibling one die prematurely. You could still get back to an interactive shell with the right signal but sl would keep annoying you by drawing a train over the top.

> Control-backslash sends SIGQUIT on the other hand. This signal cannot be trapped.

Yes, it can.

Indeed. The only signals that cannot be caught (or blocked, or ignored) are SIGKILL and SIGSTOP.
No cure, it just conditioned me into expecting to see the little train go by occasionally.
Extremely useful .gitconfig snippet:

  [alias]
   git = !sl
catches e.g. `git git status`, which I run shockingly often.
Used this years ago. It is funny the first few times and then not. Cures nothing but frustrates the hell out, especially when you are in a hurry (and that's when you make the most typos).
I so often type "nevermind" instead of "never mind" that I created a shortcut on my computer that replaces the former with the latter. I have met many other people of my generation (early 40s) who also thought it was a single word. I think we were influenced by the popular Nirvana album, which used the single-word spelling.
If enough people spell something "wrong" it automatically becomes the correct (or rather, standard) spelling, and words can have more than one correct spelling, too.
True! I've checked the dictionary several times, and we've apparently not hit the tipping point yet.
Clearly you needed to be born a little earlier so you could instead have been influenced by the proper diction of Never Mind the Bollocks, Here's the Sex Pistols.
Ah of course you meant in a word processor...

    $ never mind
    -bash: never: command not found
Thought I was about to learn about a new utility for a moment.
Welp, I also just learned it's not a single word.
Or embrace it... I don't seem to mistype ls often enough to care, but my ~/.alias has a few things of this sort

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

  alias cd..="cd .."
  alias ..="cd .."
Fish and Zsh can automatically cd into a dir if you type a path in.
the times I've typed .. dicker or focker, ducker ... or the combination of the last two .. bleh
zsh `setopt correct` is pretty helpful with these kinds of typos.
This sounded interesting but too magicky to me and I did a google search. Most of the top results are about how to disable or limit it. :)

I believe I experienced this kind of feature with fish and it was one of the reasons I didn't like it. (Most things cannot be user configured away in fish).

It works fine for me. I do have `correct_all` unset, which makes it only apply to the command and not the arguments.
I will check it out. I am sure it can be configured to work reasonably on zsh.

    alias sl=ls
Watch productivity skyrocket
alias l=ls is even better! Can't reverse the order of letters if there's just one letter.
I do the same, and also: dc=cd, wpd=pwd, tiem=time.
At a previous job, someone (with the permission to do so) installed this on a shared server, which led to one of the more ridiculous security incident tickets I saw there.
My first job was at a company where this was installed system wide on all remote linux boxes. Everytime you type sl it would take over the whole terminal for a couple of seconds leaving you unable to do anything. This was before docker & devops era so we used to ssh into machines at lot.

It was the thing that prompted me to learn tmux so I could switch tabs without needing multiple putty windows.

The original use case went away long back, but I use tmux still, so thanks I guess :)

I regularly mistype “myself” as “mysql” and vice versa. It’s like my brain registers the “mys”, figures my fingers have it covered, and checks out.
I do this for share and shader. I should symlink /usr/share to /usr/shader at this point.
I was surprised when I first came across this, to know that this was apparently such a common typo - since I don't ever recall doing this particular typo myself, even though I'm prone to character-transposition typos.

But then I realized, I rarely ever do `ls` itself - it's always either `ll` = alias for `ls -lh` or `la` = alias for `ll -A`. And those seem less typo prone, somehow.

I have no idea how I am able to type words on a computer keyboard. Its just something I somehow picked up with practice.
Had this in every Chef recipe at $previous_job. Probably still there, 7 years later.
Chefs themselves face this! Nobody wants a Chef who grabs the wrong ingredients for a recipe, accidentally rm-ing their customers.
I added an alias 'll'.

    alias ll='ls -Glopa'
and while I was at it

    alias cls='clear && printf \\e[3J'
Yes, I grew up using MS DOS, why do you ask?
> alias ll='ls -Glopa'

Does not the -o make both the -G and -l unnecessary?

Durp, you are correct. No idea how it ended up that way.
For many years it’s one of the first things I install just because I enjoy the whimsy. I’ve never reversed ls by accident though, I didn’t even realize it was a play on ls.
I have a script called wq in my path, that echoes "haha!", when I type ;wq in my shell. That is because I have swapped colon and semicolon in my vimrc.
`alias ls=sl` on your friend's unlocked computer
Just install sl. They'll see it soon enough.
Found it in my .bashrc once. That was a good trick. Now any time a buddy and I share have a login on one another's machine, the ssh motd is an ASCII train that says "toot toot".
Run `sl | lolcat` for maximum productivity.
Has anyone rewritten this in Rust yet?
Unfortunately I enter 'dc' far more often than 'sl'.
Is typing 'ls' correctly that common of a problem? =/
It is probably rare but, but if you spend most of your time on the command line it is sort of like tripping over nothing -- sticks in your memory. Particularly if it happens around other people.