11 ms·
The Fuck – Correct your previous console command
- deleted 11y ago[deleted]
- nvbn 11y agoOn some resources it's not allowed to use `fuck`, so I put `*` automatically. Now title changed to "The Fuck...".
- dr_zoidberg 11y agoAlso some mobile phones autocorrect to more "politically correct" versions, in which case this would've been replaced to "The Duck..." :P
- sixpenrose16 11y ago+1 for "The Duck".
- anigbrowl 11y agoThanks.
- JadeNB 11y agoWhile I agree with what I take to be your overall point, what would have been lost had you replaced your comment with the following, which does not assume anything about the poster's motivation? The utility is actually called "The Fuck", with no asterisk. Please respect creators by not bowdlerizing the names they have chosen.
- anigbrowl 11y agoTrue. As the title has been updated and your version is better, I'm deleting my original comment.
- JadeNB 11y agoI'm not sure if this is too much of a de-rail, and I will delete it if it is inappropriate, but I am constantly surprised by and grateful for the civility of HN, where, despite strong opinions, constructive criticism is often accepted and acted upon. Thank you for being part of that!
- hurin 11y agoNot being 100% sure which command this will correct to is dangerous. Also the need for this is largely negated by a shell with autosuggestions.
- JadeNB 11y ago> Not being 100% sure which command this will correct to is dangerous. And yet the concept of the invocation `fuck --dry-run` is surely unappealing. :-)
- iLoch 11y agoWhat if you could fuck with a small D? `fuck -d`
- sz4kerto 11y agoI don't often laugh at HN comments, but when I do, I do it hard. :)
- zak_mc_kracken 11y agoYou get easily aroused.
- igorgue 11y agoOkay that was hilarious!
- chaosfox 11y agoI think dry-run should be the default. Then if you really want to run it without checking the command first you could do: fuck --without-condom or maybe fuck --iamfeelinglucky
- jacob9706 11y agoOk. The --without-condom needs to be an option.
- 11y ago
- nine_k 11y agoI'd not use this. It's basically a negative, aggressive emotional response, exactly a thing I'd rather not experience while working. A failure due to not enough privileges might be a signal to rethink what you are doing; a mindless prepending of `sudo` is dangerous. Why not `su root` then? Also, there was that screnshot of `sudo wget` as a response to a 403 error. This is exactly why you should re-examine a failed command instead of swearing around.
- Karunamon 11y agoI would, because a lot of commands could be improved by a "do what I mean" option. GNU find is smart enough to tell me that I've placed one of the flags or the find string in the wrong place, but not smart enough to correct the fucking error and do what I meant in the first place. (It knows, it just won't do it.) "apt-get/yum install" is unusable by anyone but root. Why do I need to waste time re-keying the command? This is annoying enough that I've aliased it[1] on every machine I have access to. I'd be willing to bet the collective man hours wasted on these worthless "you did it wrong, here's how you did it wrong, now go do it right" type messages, expands well into the decades. [1]: https://github.com/Karunamon/dotfiles/blob/1174bbaee047107ea0dc87b1e4286a4445713bb8/.bash_profile_linux https://github.com/Karunamon/dotfiles/blob/1174bbaee047107ea...
- nine_k 11y ago"Do what I mean" is great as long is what you mean is what the computer infers. As everyone who wrote Perl or used MS Word knows, this is not always the case. And when it is not, it's often super annoying. How often do you run apt-get install? I bet it's not even a daily routine. (If it is, you should have already automated it.) OTOH if you run chmod or chown and it suddenly requires root privileges, it's a good idea to think a bit; a disaster may be around the corner. There are different mentalities; some crave for unconstrained aerobatics while others keep reminding to wear a parachute. I wish you all the luck, but I won't wish you be my SRE.
- camhenlin 11y agoI think it's a funny little app. I could see it being kind of useful for the author but I think I would personally have trouble using an app that I don't actually know what it's going to do 100%. I think that you could mitigate this a bit by putting the list of commands it corrects right at the top of the readme. I think most of us have probably been at the point where we were typing something like "I hate you, you god damn computer!" into the terminal or text editor. I see this as a moderately elegant helper in those situations
- libraryatnight 11y ago'I could see it being kind of useful for the author...' That was my impression. It reminded me of little custom scripts or functions I've created that help with my day to day work, things I wouldn't necessarily give to someone because they were built with myself in mind. I know how they work and exactly what they do.
- shampine 11y agoCheck out the only issue open: https://github.com/nvbn/thefuck/issues/1 https://github.com/nvbn/thefuck/issues/1 I like it, but I have to know every command it modifies/checks, I cannot run a blackbox command and hope.
- nacs 11y agoThat issue has an alias you can use: I just added an additional alias for testing. It simply outputs the command fuck would execute: alias tryfuck='thefuck $(fc -ln -1)'
- nvbn 11y agoI added info about how it works and what it can do in readme. And yep, it can add sudo to your previous rm -rf /.
- aabajian 11y agoI'm going to go out on a limb here and suggest that you rename it "The Fix." Then you could type "fixit" or just "fix".
- cpncrunch 11y agoYes, using the word "fuck" for this just strikes me as a bit immature.
- jay-saint 11y agoIf it was called the fix it never would have made it to page 1
- eli 11y agoWould make me more likely to recommend it as a serious tool to a colleague though. But then again I'm a curmudgeon.
- cpncrunch 11y agoI get the impression that it's more of a joke than a serious tool. It is actually quite funny, but I can't imagine anyone using it seriously.
- spo8 11y agoAlso if anyone really cares, they could just fork it and make the change.
- michaelmior 11y agoAnd then update it whenever the upstream changes. And keep track of all any new references which need to be modified. And publish a package if you still want it to be installed easily. And so on.
- icebraining 11y agoAmerican prudishness. There's nothing immature in swearing in and of itself.
- fifthecho 11y ago99 times out of 100, my issue is forgetting to sudo a command, so I just have 'alias fuck="sudo !!"' in my ~/.bash_profile
- agumonkey 11y agoC-o https://www.google.com/search?q=readline+operate+and+get+next https://www.google.com/search?q=readline+operate+and+get+nex...
- manojlds 11y agoGit already has a config to do this: help.autocorrect Automatically correct and execute mistyped commands after waiting for the given number of deciseconds (0.1 sec). If more than one command can be deduced from the entered text, nothing will be executed. If the value of this option is negative, the corrected command will be executed immediately. If the value is 0 - the command will be just shown but not executed. This is the default. http://git-scm.com/docs/git-config http://git-scm.com/docs/git-config
- nvbn 11y agoCool, didn't know about that before.
- keslag 11y agoAmusing, but I would prefer something that would be able to automatically know what I was meaning to do and just do it without having to be vulgar.
- gknoy 11y agoAgreed. They could even sanitize it a little bit as 'wtf' or 'oops'.
- sneak 11y agoWTF means the same thing. That is no less vulgar.
- dragonwriter 11y ago> WTF means the same thing. That is no less vulgar. Vulgarity of expressions is not a function only of what the expression means, but of the acceptability of the expression itself in various social contexts. WTF is, generally, acceptable as not excessively vulgar in social contexts where expanding the last letter of the initialism into its referent would not be, but the reverse isn't true; WTF is pretty close, therefore, to strictly less vulgar. This may not seem rational, but then the entire concept of vulgarity is irrational.
- Crito 11y ago> "WTF is, generally, acceptable as not excessively vulgar in social contexts" Which social contexts? Social contexts where people don't know what "WTF" expands to? It's not even a "minced oath".
- frenchy 11y ago"WTF" is less vulgar than "fuck" for roughly the same reason that "the f-word" is less vulgar than "fuck".
- kbenson 11y agoProjects like this always make me think the developer's imagination has drastically failed them with respect to the scope of negative consequences that may result from using their tool.
- tonyhb 11y agoProjects like this always make me think the developer's imagination is great and they must at least be intelligent enough to criticise their work (with humour).
- aerovistae 11y agoI just keep getting "No host name on command line, aborting." Also was asked to install "suck." Not sure why / what that is.
- fapjacks 11y agoOne of the issues on the Github reveals that at least one user ended up running "fsck" after typing "fuck" twice. :)
- joeminichino 11y agoFunny, when i make a mistake i exclaim "what the!" instead of "the fuck". "wot" is my suggestion for a better name.
- rjuyal 11y agoWhat the Exclamation mark.
- kylecesmat 11y agoIssue #1 is classic. Running 'Fuck' twice attempts to evaluate the previous 'Fuck'- and returns 'fsck' - which tries to forcefully check your mounted drive. I wouldn't trust this app for practical use.
- babuskov 11y agoYou can surely trust that it will 'fuck' stuff up at some point.
- alienth 11y agoFor those wanting something safer but similar, see the `fc` shell function.
- c0achmcguirk 11y agoAn issue that popped up for a user, kind of funny: https://github.com/nvbn/thefuck/issues/1 https://github.com/nvbn/thefuck/issues/1 who@where:~$ fuck No fuck given who@where:~$ fuck fsck from util-linux 2.20.1 e2fsck 1.42.9 (4-Feb-2014) /dev/sda6 is mounted. WARNING!!! The filesystem is mounted. If you continue you ***WILL*** cause ***SEVERE*** filesystem damage. Do you really want to continue<n>? no check aborted.
- baby 11y agoYup, is it possible to simulate the "up arrow" but fix it first before injecting it back into the input field of the terminal?
- _lce0 11y agoYeah, OP here. It really almost gave me a heart attack ;)
- jnetterf 11y agoIf you're less adventurous, and use fish/tmux, you could try something like: # config.fish function fuck thefuck (history | head -n1) | tmux load-buffer - tmux paste-buffer -s \0 end This will paste the command The Fuck suggests without a return so you can audit the corrected command before running it.
- Bud 11y agoIn other words: don't go fuck yourself! ;)
- aviraldg 11y ago.. ten seconds until there's outrage against the name and a campaign to have it cleaned up. (see: Karma) Very useful though.
- whizzkid 11y agoI think i will continue using the Fish shell feature instead. It has this awesome feature of autocompleting your command with the bash history of yours. It is safe because it will autocomplete a command that you wrote before. Another cool thing with it is that, it will list the commands that you can run after entering a word. It does this by reading the man page of the command you write. brew <Tab> will list the brew commands for you to use with its explanations.
- scottmwinters 11y agoyea, lots of us use shells with suggestive text...that doesn't make this less amusing. Now if only someone would make rules for my osx terminal, thatd be great
- soheil 11y agoI praise you for giving us the fuck!
- zenojevski 11y agoHere's an equivalent "alias" for the fish shell: function fuck eval (thefuck (history | head -n1)) end
- nvbn 11y agoThanks, added to readme.
- brento 11y agoThis looks very helpful ... however, could we get a PG version like "The Crap"?
- sneak 11y agoPeople are not materially harmed by short strings, so no.
- benmcnelly 11y agoWhat if they were objects?
- Tenobrus 11y agoFork it if you care that much. Looks like someone already has, actually: https://github.com/shaungallagher/thefudge https://github.com/shaungallagher/thefudge But seriously, I can't some up with a single situation where using "fudge/crap" instead of fuck would matter.
- jryan49 11y agoMade an Arch AUR package. First time making VCS package. Might be terrible. https://aur.archlinux.org/packages/thefuck-git/ https://aur.archlinux.org/packages/thefuck-git/
- cevaris 11y agoGot to love https://github.com/nvbn/thefuck/issues/5 https://github.com/nvbn/thefuck/issues/5
- deleted 11y ago[deleted]
- csandreasen 11y agoCool idea. For those systems where you don't have the option of adding a 3rd party tool, it's probably worth knowing some of the standard bash shortcuts. The easy to remember ones are: !^ - the first argument from the previous command !$ - the last argument from the previous command !* - all of the arguments from the previous command !! - the entire previous command For example: $ apt-get install foo # Crap $ sudo !!
- melling 11y agoTypo correction is useful too. ^foo^bar git brnch ^r^ra This works on all Unix machines
- stewartbutler 11y ago*Works if properly implemented. Had to manually disable this behavior in eshell as it prevented you from running regex with two carets, e.g. '$ grep -E '^sometext[^ ]+moretext'. You can also just run a sed style substitution in most shells, e.g. '$ !!:s/before/after/' or '$ !!:gs/x/y/', which is safer IMO.
- lectrick 11y agoYou know... I've seen this notation on discussion forums (and probably IRC etc.) for years, and had no idea until now that it was a reference to this shell capability lol
- stox 11y agoBTW, all of those commands are from the original BSD c-shell. Bash developers knew a good thing when they saw it.
- ferrari8608 11y agoI've been using "sudo !!" (which I pronounce as sudo bangbang in my head) for a while now, mostly with vim for editing stuff in /etc. It's very nifty. Another nifty tool is vi editing mode. You run "set -o vi", and now your shell takes vi modal editing commands. That along with Ctrl-r for reverse history search has made life in the shell so much easier. Bash has a ton of little stuff like that built in. Zsh has a few more.
- mayneack 11y agoMildly related: http://bropages.org/ http://bropages.org/
- sgtpep 11y agoOut of the box bash trick: export EDITOR=vim C-p (or Up) C-x C-e
- ChristianBundy 11y agoI wrote a similar Sudo History Invocation Tool to do this: https://github.com/christianbundy/shit https://github.com/christianbundy/shit
- bharad 11y agoAlso, fix command might help $ fc
- dbbolton 11y agoZsh's completion system handles most of those examples if enabled: http://zsh.sourceforge.net/Guide/zshguide06.html#l162 http://zsh.sourceforge.net/Guide/zshguide06.html#l162 http://zsh.sourceforge.net/Doc/Release/Shell-Grammar.html http://zsh.sourceforge.net/Doc/Release/Shell-Grammar.html http://zsh.sourceforge.net/Doc/Release/Expansion.html http://zsh.sourceforge.net/Doc/Release/Expansion.html It can actually be integrated into history expansion, used at will, configured with a custom prompt, told to ignore certain words and files that annoy you, etc. But if you try to search for "zsh correction", most posts are related to disabling it entirely.
- jacob9706 11y agoAdded the `fuck --dry` option from the comments below, waiting for it to be merged. All it does is print the command to run and prompts for [Y/n].
- JulianMorrison 11y ago$ rm -rf / oops permission denied $ fuck sudo rm -rf --no-preserve-root / oops $ _
- LfLxfxxLxfxx 11y agoI was expecting to see in the examples: $ wrongcommand error $ fcuk command not found $ fuck
- abc_lisper 11y agoThis.
- bane 11y agoI've started to wonder why we've never seen a more IDE-like autocomplete in consoles. I mean, why do I have to use man pages and all sorts of reference guides to remember the parameters for find or grep or whatever, or the order of commands for whatever? There really needs to be better communication between software and the environment it's running in.
- Symmetry 11y agoI feel like fish gets part of the way there by grabbing stuff from the man pages and displaying descriptions in tab-complete options. But we're still a ways from the anti-Mac user interface[1]. Unless maybe you count Google's search bar. [1]http://www.nngroup.com/articles/anti-mac-interface/ http://www.nngroup.com/articles/anti-mac-interface/
- abc_lisper 11y agoI will not let my coworkers see me typing expletives into terminal; much less if it is a woman. It is a nice idea, though. Will use it if it's called auto-correct or something.
- danellis 11y agoI'm not sure what difference you think gender makes, unless you think women are delicate flowers that must be sheltered from bad language, but I do agree that it would be better named something more office friendly. I'd suggest 'argh', 'grr' or 'gah'.
- genderbar 11y agoProfanity is (deliberately) uncomfortable to people who are not part of your in-group. Women are more likely to be/feel excluded from in-groups in technology workplaces.
- lesmiserable 11y agoProfanity is a wonderful spice of life, it is deliberately uncomfortable to people who take things way too seriously.
- genderbar 11y agoGet back to me after someone you don't like or don't trust throws you some of that spice.
- lesmiserable 11y agoyou mean like being in any public space? I only get to control how I react.
- danellis 11y ago> Women are more likely to be/feel excluded from in-groups in technology workplaces ... because people want to treat them differently, perhaps?
- dheera 11y agoWhat I really want is a wrapper for sudo. Whenever I use sudo, if type the password correctly it works instantly; if I mistype the password, it delays for 2 seconds before asking again. Often it's faster to Ctrl+C UP ENTER than to wait for that annoying 2 seconds. So it would be nice if a wrapper existed to see if sudo gives access within 0.1 seconds, and if it doesn't, assume the password was wrong, kill the sudo process and launch the command again. Automate the Ctrl+C UP ENTER.
- juliansimioni 11y agoI suspect the delay in sudo is configurable: it's not there because sudo is actually doing any work checking your password, it's there to prevent attackers from trying many many combinations of passwords quickly. If you care about that protection, then you don't want to circumvent it, but in the equally reasonable case where you don't care, then you can probably just make sudo faster.
- ferrari8608 11y agoYou can limit the amount of retries, so a delay between attempts by default seems a little silly to me.
- dlgeek 11y agoIt actually comes from PAM - man pam_faildelay
- dheera 11y agoHow is it offering protection? An attacker could use this scheme as well. If the server doesn't let the user through in 0.1 s, abort and retry the connection, circumventing the delay.
- vinceyuan 11y agoSuper interesting. I LOLed. But I will not install it.
- nullc 11y agoI wonder if the name came from some version of this pithy one-liner: To err is human, to really fuck things up requires a computer.
- bcheung 11y agoThe birth of a new metric: alias WTFs="history | grep fuck | wc -l"
- pervycreeper 11y agoI'm not quite sure I understand why this is any better than using the up arrow. I thought the cardinal rule of sysadmins was "think before you press enter". This seems to discourage that mindset.
- mormegil 11y ago"In one notorious incident, Warren added a DWIM feature to the command interpreter used at Xerox PARC. One day another hacker there typed delete $ to free up some disk space. (The editor there named backup files by appending $ to the original file name, so he was trying to delete any backup files left over from old editing sessions.) It happened that there weren't any editor backup files, so DWIM helpfully reported $ not found, assuming you meant 'delete *'." See http://www.catb.org/jargon/html/D/DWIM.html http://www.catb.org/jargon/html/D/DWIM.html and also https://en.wikipedia.org/wiki/DWIM https://en.wikipedia.org/wiki/DWIM
- cfrs 11y agoSomeone should fork fish and create fuckfish: a shell that fucks automatically
- anonbanker 11y agoI've created perl scripts for fuck, shit, and goddamnit. they merely echo an array slice to the terminal, from a list of about 30 phrases. had 'em for about 15 years now. <root@ButtPirate>$ fuck I hope this computer dies of ass cancer. always makes me feel a little better about life. this app might be more effective, though.
- alfasin 11y agoalias fuck='sudo $(history -p \!\!)'
- _ZeD_ 11y agoit's only me to just tap "up" and edit the command?
- foxhop 11y agoUnix 'fc' or fix command