Hacker News new | ask | show | jobs
by donquix 4916 days ago
sudo !!

Instant favorite

3 comments

I often alias `sudo` to `fucking` to help vent my frustrations

    $ rm -rf somedir
    rm: somedir/: Permission denied
    $ fucking !!
I have been known to use sudo when it is not appropriate to use the f-word ;)
Along the lines of magic shell variables, there's also '!$', which selects the last argument of the previous command. Often I'm looking at different aspects of the same file:

    $ file foo
    $ ls -lh !$
    $ vim !$
I don't find this one useful. [up-arrow] automatically inserts the last command, which gives a generic mechanism to correct the command and it requires no more typing than !!: [up-arrow][control-a]sudo [enter]
moving your hand over to arrow keys is why I would use the sudo !! version.
[control-p] then ;)