TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

The Fuck – Correct your previous console command

438 pointsby nvbnabout 10 years ago

44 comments

csandreasenabout 10 years ago
Cool idea. For those systems where you don&#x27;t have the option of adding a 3rd party tool, it&#x27;s probably worth knowing some of the standard bash shortcuts. The easy to remember ones are:<p><pre><code> !^ - 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 </code></pre> For example:<p><pre><code> $ apt-get install foo # Crap $ sudo !!</code></pre>
评论 #9397858 未加载
评论 #9399051 未加载
评论 #9397043 未加载
评论 #9397035 未加载
评论 #9398385 未加载
评论 #9398070 未加载
评论 #9401230 未加载
评论 #9399488 未加载
评论 #9397459 未加载
c0achmcguirkabout 10 years ago
An issue that popped up for a user, kind of funny:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;nvbn&#x2F;thefuck&#x2F;issues&#x2F;1" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nvbn&#x2F;thefuck&#x2F;issues&#x2F;1</a><p><pre><code> who@where:~$ fuck No fuck given who@where:~$ fuck fsck from util-linux 2.20.1 e2fsck 1.42.9 (4-Feb-2014) &#x2F;dev&#x2F;sda6 is mounted. WARNING!!! The filesystem is mounted. If you continue you ***WILL*** cause ***SEVERE*** filesystem damage. Do you really want to continue&lt;n&gt;? no check aborted.</code></pre>
评论 #9397847 未加载
评论 #9396608 未加载
评论 #9397448 未加载
评论 #9399914 未加载
manojldsabout 10 years ago
Git already has a config to do this:<p><pre><code> 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. </code></pre> <a href="http:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;git-config" rel="nofollow">http:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;git-config</a>
评论 #9396814 未加载
hurinabout 10 years ago
Not being 100% sure which command this will correct to is dangerous. Also the need for this is largely negated by a shell with autosuggestions.
评论 #9396313 未加载
评论 #9396537 未加载
评论 #9396503 未加载
评论 #9396505 未加载
评论 #9396340 未加载
评论 #9398020 未加载
fifthechoabout 10 years ago
99 times out of 100, my issue is forgetting to sudo a command, so I just have &#x27;alias fuck=&quot;sudo !!&quot;&#x27; in my ~&#x2F;.bash_profile
评论 #9398042 未加载
dbboltonabout 10 years ago
Zsh&#x27;s completion system handles most of those examples if enabled:<p><a href="http:&#x2F;&#x2F;zsh.sourceforge.net&#x2F;Guide&#x2F;zshguide06.html#l162" rel="nofollow">http:&#x2F;&#x2F;zsh.sourceforge.net&#x2F;Guide&#x2F;zshguide06.html#l162</a><p><a href="http:&#x2F;&#x2F;zsh.sourceforge.net&#x2F;Doc&#x2F;Release&#x2F;Shell-Grammar.html" rel="nofollow">http:&#x2F;&#x2F;zsh.sourceforge.net&#x2F;Doc&#x2F;Release&#x2F;Shell-Grammar.html</a><p><a href="http:&#x2F;&#x2F;zsh.sourceforge.net&#x2F;Doc&#x2F;Release&#x2F;Expansion.html" rel="nofollow">http:&#x2F;&#x2F;zsh.sourceforge.net&#x2F;Doc&#x2F;Release&#x2F;Expansion.html</a><p>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 &quot;zsh correction&quot;, most posts are related to disabling it entirely.
camhenlinabout 10 years ago
I think it&#x27;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&#x27;t actually know what it&#x27;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.<p>I think most of us have probably been at the point where we were typing something like &quot;I hate you, you god damn computer!&quot; into the terminal or text editor. I see this as a moderately elegant helper in those situations
评论 #9396520 未加载
评论 #9396829 未加载
评论 #9396479 未加载
mormegilabout 10 years ago
&quot;In one notorious incident, Warren added a DWIM feature to the command interpreter used at Xerox PARC. One day another hacker there typed delete <i>$ 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&#x27;t any editor backup files, so DWIM helpfully reported </i>$ not found, assuming you meant &#x27;delete *&#x27;.&quot; See <a href="http:&#x2F;&#x2F;www.catb.org&#x2F;jargon&#x2F;html&#x2F;D&#x2F;DWIM.html" rel="nofollow">http:&#x2F;&#x2F;www.catb.org&#x2F;jargon&#x2F;html&#x2F;D&#x2F;DWIM.html</a> and also <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;DWIM" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;DWIM</a>
ChristianBundyabout 10 years ago
I wrote a similar Sudo History Invocation Tool to do this: <a href="https:&#x2F;&#x2F;github.com&#x2F;christianbundy&#x2F;shit" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;christianbundy&#x2F;shit</a>
dheeraabout 10 years ago
What 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&#x27;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&#x27;t, assume the password was wrong, kill the sudo process and launch the command again. Automate the Ctrl+C UP ENTER.
评论 #9397704 未加载
aviraldgabout 10 years ago
.. ten seconds until there&#x27;s outrage against the name and a campaign to have it cleaned up. (see: Karma)<p>Very useful though.
baneabout 10 years ago
I&#x27;ve started to wonder why we&#x27;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?<p>There really needs to be better communication between software and the environment it&#x27;s running in.
评论 #9397588 未加载
kbensonabout 10 years ago
Projects like this always make me think the developer&#x27;s imagination has drastically failed them with respect to the scope of negative consequences that may result from using their tool.
评论 #9397626 未加载
jacob9706about 10 years ago
Added the `fuck --dry` option from the comments below, waiting for it to be merged.<p>All it does is print the command to run and prompts for [Y&#x2F;n].
kylecesmatabout 10 years ago
Issue #1 is classic.<p>Running &#x27;Fuck&#x27; twice attempts to evaluate the previous &#x27;Fuck&#x27;- and returns &#x27;fsck&#x27; - which tries to forcefully check your mounted drive.<p>I wouldn&#x27;t trust this app for practical use.
评论 #9397047 未加载
cevarisabout 10 years ago
Got to love <a href="https:&#x2F;&#x2F;github.com&#x2F;nvbn&#x2F;thefuck&#x2F;issues&#x2F;5" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nvbn&#x2F;thefuck&#x2F;issues&#x2F;5</a>
whizzkidabout 10 years ago
I 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.<p>It is safe because it will autocomplete a command that you wrote before.<p>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.<p>brew &lt;Tab&gt; will list the brew commands for you to use with its explanations.
abc_lisperabout 10 years ago
I will not let my coworkers see me typing expletives into terminal; much less if it is a woman.<p>It is a nice idea, though. Will use it if it&#x27;s called auto-correct or something.
评论 #9397577 未加载
评论 #9397670 未加载
评论 #9397633 未加载
bcheungabout 10 years ago
The birth of a new metric:<p>alias WTFs=&quot;history | grep fuck | wc -l&quot;
zenojevskiabout 10 years ago
Here&#x27;s an equivalent &quot;alias&quot; for the fish shell:<p><pre><code> function fuck eval (thefuck (history | head -n1)) end</code></pre>
评论 #9396848 未加载
jryan49about 10 years ago
Made an Arch AUR package. First time making VCS package. Might be terrible.<p><a href="https:&#x2F;&#x2F;aur.archlinux.org&#x2F;packages&#x2F;thefuck-git&#x2F;" rel="nofollow">https:&#x2F;&#x2F;aur.archlinux.org&#x2F;packages&#x2F;thefuck-git&#x2F;</a>
pervycreeperabout 10 years ago
I&#x27;m not quite sure I understand why this is any better than using the up arrow.<p>I thought the cardinal rule of sysadmins was &quot;think before you press enter&quot;. This seems to discourage that mindset.
agumonkeyabout 10 years ago
C-o <a href="https:&#x2F;&#x2F;www.google.com&#x2F;search?q=readline+operate+and+get+next" rel="nofollow">https:&#x2F;&#x2F;www.google.com&#x2F;search?q=readline+operate+and+get+nex...</a>
_ZeD_about 10 years ago
it&#x27;s only me to just tap &quot;up&quot; and edit the command?
aerovistaeabout 10 years ago
I just keep getting &quot;No host name on command line, aborting.&quot;<p>Also was asked to install &quot;suck.&quot; Not sure why &#x2F; what that is.
评论 #9396637 未加载
mayneackabout 10 years ago
Mildly related: <a href="http:&#x2F;&#x2F;bropages.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;bropages.org&#x2F;</a>
nullcabout 10 years ago
I wonder if the name came from some version of this pithy one-liner:<p>To err is human, to really fuck things up requires a computer.
LfLxfxxLxfxxabout 10 years ago
I was expecting to see in the examples:<p><pre><code> $ wrongcommand error $ fcuk command not found $ fuck</code></pre>
评论 #9397561 未加载
anonbankerabout 10 years ago
I&#x27;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 &#x27;em for about 15 years now.<p><pre><code> &lt;root@ButtPirate&gt;$ fuck I hope this computer dies of ass cancer. </code></pre> always makes me feel a little better about life. this app might be more effective, though.
sgtpepabout 10 years ago
Out of the box bash trick:<p><pre><code> export EDITOR=vim C-p (or Up) C-x C-e</code></pre>
cfrsabout 10 years ago
Someone should fork fish and create fuckfish: a shell that fucks automatically
alienthabout 10 years ago
For those wanting something safer but similar, see the `fc` shell function.
scottmwintersabout 10 years ago
yea, lots of us use shells with suggestive text...that doesn&#x27;t make this less amusing. Now if only someone would make rules for my osx terminal, thatd be great
vinceyuanabout 10 years ago
Super interesting. I LOLed. But I will not install it.
bharadabout 10 years ago
Also, fix command might help<p>$ fc
joeminichinoabout 10 years ago
Funny, when i make a mistake i exclaim &quot;what the!&quot; instead of &quot;the fuck&quot;. &quot;wot&quot; is my suggestion for a better name.
评论 #9396614 未加载
soheilabout 10 years ago
I praise you for giving us the fuck!
foxhopabout 10 years ago
Unix &#x27;fc&#x27; or fix command
JulianMorrisonabout 10 years ago
$ rm -rf &#x2F; oops<p>permission denied<p>$ fuck<p>sudo rm -rf --no-preserve-root &#x2F; oops<p>$ _
alfasinabout 10 years ago
alias fuck=&#x27;sudo $(history -p \!\!)&#x27;
aabajianabout 10 years ago
I&#x27;m going to go out on a limb here and suggest that you rename it &quot;The Fix.&quot; Then you could type &quot;fixit&quot; or just &quot;fix&quot;.
评论 #9396630 未加载
评论 #9396500 未加载
评论 #9396912 未加载
评论 #9398113 未加载
brentoabout 10 years ago
This looks very helpful ... however, could we get a PG version like &quot;The Crap&quot;?
评论 #9396806 未加载
评论 #9397380 未加载
keslagabout 10 years ago
Amusing, 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.
评论 #9396492 未加载
nine_kabout 10 years ago
I&#x27;d not use this.<p>It&#x27;s basically a negative, aggressive emotional response, exactly a thing I&#x27;d rather not experience while working.<p>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?<p>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.
评论 #9396865 未加载