
The Fuck – An app which corrects your previous console command - claroscuro
https://github.com/nvbn/thefuck
======
Johnny555

      [~user/]$ rm -rf /
      rm: it is dangerous to operate recursively on `/'
      rm: use --no-preserve-root to override this failsafe
      [~user/]$ fuck
      sudo rm -rf --no-preserve-root /
    

_fuck!_

~~~
nvbn
Rule for this behavior disabled by default, but you can enable it. Also you
can disable confirmation or use `fuck -y` for more fun.

~~~
hinkley
I feel like they missed an opportunity to use 'fuck yeah' as the automatic
override.

~~~
derefr

        alias just=sudo
        just fuck -me -up

~~~
pharrington
This is Art. Thank you for doing Art on HN.

------
madmax108
I use this regularly, for everything ranging from the forgotten sudo (instead
of running "sudo !!") to typos across the board.

But it does get me into interesting situations! Just the other day I was demo-
ing something to my team + Director of Engg on the projector, and I ran an
incorrect command, followed by "fuck" to fix it, leading to so many stares :P

Just as an FYI, you can change the prompt from fuck to something else by
changing your .bashrc eg.:

    
    
        eval "$(thefuck-alias fixit)"
    

I'm not changing my alias though! ;)

~~~
freecodyx
funny!, next time i am demoing, i will try to do it, to show off obviously

------
evanb
I often set `alias fucking='sudo'`.

    
    
        >$ make me a sandwich
        permission denied
        >$ fucking make me a sandwich
        [or]
        >$ fucking !!

~~~
joshmanders
I have the same.

    
    
        # Because sometimes you gotta be harsh.
        alias fucking="sudo"
        
        # And sometimes you gotta be nice.
        alias please="sudo"

------
dang
Previously discussed at
[https://news.ycombinator.com/item?id=9396116](https://news.ycombinator.com/item?id=9396116).

~~~
i336_
I see why you linked that.

My brain nearly double faulted from learning new things too fast. Great
thread.

~~~
the_denial
Hi. Thanks for catching the JS injection and shock site redirect bug. I fixed
it.

~~~
i336_
Ah, good to hear. Sorry it happened.

Since
[https://news.ycombinator.com/item?id=14144814](https://news.ycombinator.com/item?id=14144814)
got locked (which, to provide context for anyone else reading, is why this
reply is here in this thread) maybe you could repost it now.

FWIW, this idea in and of itself is worth spending a bit of time on. The page
itself is very... basic right now, and I wouldn't discount that this may be
one major reason why nobody is taking the concept seriously.

Which makes sense: nobody knows what your areas of specialty and experience
are, what you're capable of, and all they've got is this very barebones page.
Noone knows what to suggest for you to do!!

Spending some time on the page design and specifying the kinds of things
you're capable of - and, most importantly, the things you're most interested
in - might just turn things around a fair bit.

Thanks for the ping :) and hopefully you see this.

I note you have not yet put any contact info on that page :P (Gmail happily
forwards, and Outlook (which forwards too) also has aliases)

My email is in my profile FWIW. You could also drop your username on the page
and tell people to "find your email on HN". That could be a good filter.

------
JoshCole
If you mistype _fuck_ , does it properly recurse up the _fuck_ chain?

~~~
zuck9

        > fsck
        ERROR: volume / is mounted with write access. Re-run with (-l) to freeze volume.
        > fuck
        No fucks given

------
Symmetry
Another step towards the Anti-Mac user interface.

[https://www.nngroup.com/articles/anti-mac-
interface/](https://www.nngroup.com/articles/anti-mac-interface/)

~~~
_xgw
What would be the Mac design principle way of doing this then? Would every
command line tool then be an Anti-Mac user interface?

~~~
Symmetry
More or less helping move from 'direct manipulation' to delegation. It's not
so much that this is moving away from any particular Mac principle so much as
towards the sort of system outlined in that essay.

------
ryandrake
Would be nice to have some form of autocorrect directly in the shell,
especially if it was aware of common programs and so could also autocorrect
options. Obviously we could think of a few cases with destructive outcomes--
but that doesn't make it a bad feature.

git stauts

I mean, git knows enough to ask me "Did you mean this? status".

~~~
hashhar
Add this to gitconfig file. It will automatically run the correct command
after displaying what it is after a delay.

The value is in 0.1s (centiseconds) of seconds. So 20 means 2 seconds.

[help]

autocorrect = 20

OR run git config --global help.autocorrect 20

~~~
Pxtl
Wouldn't those be deciseconds? Also wtf unit. Use Millis or seconds as a
float. Yay Linus making sure that git only makes sense to wizards like him.

~~~
LnxPrgr3
The Linux kernel seems to have a centisecond obsession too. Probably from way
back when HZ was 100 and your computer woke up once every centiseecond to make
sure it still had nothing to do.

------
leesalminen
This will definitely help some co workers who aren't CLI-savvy and always tell
me their commands "didn't work".

~~~
styfle
You have the problem too? Everyone comes to me when the get a conflict because
they don't read the part that says when you're done, do `git rebase
--continue`

------
beausy
An oldie that has been passed around in various incarnations since the 2000s
is an alias also called fuck which repeats the last command with sudo. Either
coincidence or perhaps it could be where the inspiration for this project came
from.

    
    
        alias fuck='sudo $(history -p \!\!)'

------
varunagrawal
Didn't this appear on Hacker News years ago? I have been using it since and
absolutely love it!

~~~
ChrisArchitect
wow yeah, this is what, 2+ years old?

------
iagooar
My favorite shell typo: dicker instead of docker. More funny if you speak
German :)

~~~
floatboth
Reminds me of [http://anafenza.tumblr.com/post/154944486277/humming-bird-
mo...](http://anafenza.tumblr.com/post/154944486277/humming-bird-moth-
discoursestorm)

------
whistlerbrk
Love it, have thought about it, but my one concern always is that it'll lead
to a decrease in my typing skills instead of reinforcing good keying. But
fuck, I just need to get stuff done sometimes.

~~~
eric_h
Personally my typo rate has held pretty steady over the last decade, I don't
think something like this would have any measurable effect on how well one
types.

My concern would be that the extra keystroke to confirm would ingrain the skip
confirm (fuck -y, or even just hitting enter before I'm prompted again) into
my muscle memory, with potentially disastrous consequences (hence I've never
installed this tool).

------
bogomipz
Is this any easier though than the using the carat style previous command
substitution?

    
    
        ^bar^baz
    

Although I think the name might be more descriptive.

~~~
dsl
I don't understand how you think anything is easier than typing 'fuck' and
have it identify and correct your mistake for you?

~~~
bogomipz
Lets see in order to use "fuck" I need to first install it and its
dependencies. The caret substitution natively exists in the Bash shell.

Also I know that no matter what system I am on be it OS X or Linux the caret
syntax is guaranteed to work.

I don't understand how you think anything can be easier than using the
functionality that has existed in the Bash shell shell(or even C shell
variants)since forever.

~~~
Retra
If that were how things worked, we'd never use any new technology. Obviously
it is easier to pay a one-time up-front cost than to slog away inefficiently
forever.

~~~
bogomipz
>"If that were how things worked, we'd never use any new technology"

Nice try. That's a straw man. This isn't new technology. Its simply
replicating existing functionality.

>"Obviously it is easier to pay a one-time up-front cost than to slog away
inefficiently forever"

Whats the average typo 1 character as in most of the demos for "Fuck"? So I
can either type 2 carets and 4 letters for a total of 6 characters or I can
type the 4 characters in the word "fuck", how is the former inefficient? Wow,
what a slog. I can't imagine what I will do with all the time I will have left
over after installing this"

~~~
vacri
Speaking of straw men, this program does more than simple typo substitution.
The listed examples include prepending sudo and using git-suggested commands.

~~~
bogomipz
>"The listed examples include prepending sudo"

Which you can get by typing:

    
    
        sudo !!
    

and git completion is in contrib:

[https://github.com/git/git/tree/master/contrib/completion](https://github.com/git/git/tree/master/contrib/completion)

Not really a strawman is it?

~~~
vacri
Well, yes it is, because again, I was just giving examples. Look at the list
under "how it works" in the readme, and there's plenty of items there that
aren't simple substitution. It'd be a lot easier to just 'fuck' for most of
those than have to mentally parse what you need to do to 'fix it'.

------
excalibur
This is wonderful.

------
m4tthumphrey
Every day:

$ git pish

$ fuck

~~~
artursapek
alias gp="git push" has probably saved me hours of my life

~~~
madmax108
Amen.

My bashrc has so many of these, and they're probably among the most common
commands I use daily!:

    
    
        alias gs="git status"
        alias gb="git branch"
        alias grh="git reset --hard"
        alias gcdf="git clean -df"
        alias gf="git fetch"
        alias gp="git pull"
        alias gdom="git diff origin/master"
        alias gdomn="git diff --name-status origin/master"
        alias gd="git diff"
        alias gl="git log"
        alias glm="git log --author <my_name>"
        alias gc="git checkout"
        alias gcm="git checkout master"

~~~
amelius
Or how about git commit with a dummy message? :)

~~~
jurie
Like this?

    
    
      $ cat << EOF > ~/.commit_reasons; strfile ~/.commit_reasons
      Testing...
      %
      Testify...
      %
      Testarossa...
      %
      Does it work yet?
      %
      How bout now?
      %
      Oops.
      %
      Fixed a thing.
      %
      EOF
      
      $ fortune ~/.commit_reasons | cowsay | git -F -

~~~
tfn
Even better:
[https://news.ycombinator.com/item?id=5666160](https://news.ycombinator.com/item?id=5666160)

------
jianshen
Now do ffmpeg! (Seriously I would pay for autocomplete ffmpeg cmd line
options)

~~~
nvbn
It can't help with autocomplete, but I guses it would be easy to create a rule
for fixing incorrect ffmpeg calls.

Create an issue about that in
[https://github.com/nvbn/thefuck/issues](https://github.com/nvbn/thefuck/issues)

------
7ewis
This seems fairly similar to the command auto-correction in Oh My Zsh.

~~~
amaterasu
It's zsh itself, not Oh My Zsh, controlled via the `correct` option.

~~~
7ewis
Thanks, I wasn't too sure. I have always used them together!

------
cnp
I use this app SO MUCH and recommend it to everyone. Great work!

------
formula_ninguna
What if I misspell the word "fuck"?

------
axonic
cursing is now provably productive

------
dingo_bat
It's a nice utility. But I stopped using it because it keeps messing up my
bash history.

------
5_minutes
+1 for not being PC

~~~
nix0n
Actually, it does appear to work on PCs.

~~~
ktta
I think you are joking, but he meant PC as in Politically Correct

