Live data from Hacker News

The Fuck – Correct your previous console command

github.com

121–130 of 173 posts

Re: The Fuck – Correct your previous console command

#121

Earlier quoted context omitted.

I'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…

Probably my biggest overall timesaver has been: :w !sudo tee % If you neglected to sudo before making your changes.

I've had this in my vimrc for years:

   " Let :w!! gain sudo privileges without closing and reopening vim
   cmap w!! w !sudo tee % >/dev/null

Re: The Fuck – Correct your previous console command

#122
post #8

I'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 co…

I 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?…

"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.

Re: The Fuck – Correct your previous console command

#123

Cool 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 !!

I'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…

I also use that all the time, and pronounce it as "sudo", but with more excitement.

Re: The Fuck – Correct your previous console command

#124
post #6

Earlier quoted context omitted.

> 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. :-)

I 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

--bareback?

Re: The Fuck – Correct your previous console command

#126

99 times out of 100, my issue is forgetting to sudo a command, so I just have 'alias fuck="sudo !!"' in my ~/.bash_profile

Check it out: https://github.com/seletskiy/dotfiles/blob/master/.zsh/alias...

Far more easier to press CTRL-T than type `fuck` every time.

Re: The Fuck – Correct your previous console command

#128
post #109

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'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 pr…

I 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.

It actually comes from PAM - man pam_faildelay

Re: The Fuck – Correct your previous console command

#129

Cool 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 !!

You can also specify a specific argument number from the previous command with colon notation e.g. sudo dpkg -l !:2
Post reply on HN