News for hackers. Stuff that matters.
Re:The Fuck – Correct your previous console command by ferrari8608 on Friday April 17, 2015 @06:09PM (#9397459)
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 more.

Re:The Fuck – Correct your previous console command by dogecoinbase on Friday April 17, 2015 @07:04PM (#9397679)
Probably my biggest overall timesaver has been:

   :w !sudo tee %
If you neglected to sudo before making your changes.
Re:The Fuck – Correct your previous console command by mattikus on Friday April 17, 2015 @08:24PM (#9397891)
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 by mkagenius on Saturday April 18, 2015 @03:02AM (#9398565)
Its much more easier to remember when you know how that actually works. Here is link explaining how that actually works:

http://stackoverflow.com/questions/2600783/how-does-the-vim-...

Re:The Fuck – Correct your previous console command by vram22 on Saturday April 18, 2015 @04:49AM (#9398767)
Yes, that vi editing mode of bash is very useful. IIRC it was there in ksh too. Some people might not know that you can use both the insert/append mode and the command mode of vi(m) in that vi editing mode of bash, to edit previously entered commands. You just switch between the two modes the same way as you do in the real vi(m), with ESC to go from insert/append mode to command mode, and i or a to go from command mode to insert/append mode.

Also, after you have entered a previous command, to edit it, or any previous command in the history, the first thing you have to do is press ESC (to go to command mode) and then k, thereby bring the last entered command into view for editing.

When editing a command, but in command mode (not insert/append mode), you can also press v to open the command in vi(m) in a temporary file, then have the full screen editor at your disposal to edit the command (useful for long scripts including for/while loops or long pipelines), and then when you save and exit (:wq or :x followed by Enter), the newly edited command gets executed by bash.

Also, this editing technique is useful not only for correcting typos in commands, but for modifying a previous correct command, to change some words in it and then re-issue it.

Re:The Fuck – Correct your previous console command by jpwright on Friday April 17, 2015 @09:15PM (#9397997)
I also use that all the time, and pronounce it as "sudo", but with more excitement.
Re:The Fuck – Correct your previous console command by vehementi on Saturday April 18, 2015 @02:57AM (#9398554)
sudo !! is my favorite thing. I named my cat sudo bangbang.
Re:The Fuck – Correct your previous console command by okasaki on Saturday April 18, 2015 @04:15AM (#9398700)
I don't see the advantage over pressing up, C-a and typing sudo
Re:The Fuck – Correct your previous console command by LukeShu on Saturday April 18, 2015 @12:08PM (#9399902)
Historically: it predates the ability to do interactive line-editing.