Hacker News new | ask | show | jobs
by yjftsjthsd-h 457 days ago
> and I’ve come across more than one paid professional who doesn’t use the “up” key to retrieve the previous command.

Well. I prefer ctrl-p personally, but I take your point:)

2 comments

I'm a `!!` man.
Especially since it fits nicely into a mental model that includes !*, !^, !$, !-2 and such. ^something^somethingelse is also useful.

And the sudo !! pattern is something I do even when I realize that I need root ahead of time. There’s something about hitting enter on a command that makes me realize I’ve made a mistake, so doing that before I’ve granted root permissions is helpful. Up/ctrl-p are more awkward to use this way.

I also like typing `!:` (in zsh) and hitting tab and getting some helpful hints:

    $ !:
    &  -- repeat substitution
    A  -- as ':a', then resolve symlinks
    P  -- realpath, resolve '..' physically
    Q  -- strip quotes
    a  -- absolute path, resolve '..' lexically
    c  -- PATH search for command
    e  -- leave only extension
    g  -- globally apply s or &
    h  -- head - strip trailing path element
    l  -- lower case all words
    p  -- print without executing
    q  -- quote to escape further substitutions
    r  -- root - strip suffix
    s  -- substitute string
    t  -- tail - strip directories
    u  -- upper case all words
    x  -- quote words, breaking on whitespace
I do <Esc>k