News for hackers. Stuff that matters.
Re:Unix tricks by ralph on Thursday March 07, 2013 @12:55PM (#5339027)
No, that gives the last word, as you say, we want the dirname of the last word.

    $ echo foo/bar
    foo/bar
    $ echo !$ !$:h
    foo/bar foo
Re:Unix tricks by kragen on Tuesday March 12, 2013 @04:12PM (#5364547)
So you say cd M-. M-backspace M-backspace instead of cd M-.. Four keystrokes is still an improvement over shift-1 shift-4 shift-; h, which is five, plus you get to see where you're going to go before you get there.
Re:Unix tricks by ralph on Tuesday March 12, 2013 @10:06PM (#5366352)
You're incorrect. The number of M-backspace you appear to need would seem to depend on how many `little' words comprise the part that needs deleting, e.g. foo/2013-03-13 needed three M-backspace to rid me of the date and a further backspace to remove the trailing slash, which isn't insignificant to all commands, e.g. ls -ld bar/ when bar is a symlink.

In comparison. !$:h understands its task at a higher level. And thanks to key rollover, typing different characters, like !$:h, is quicker than tapping away at . until visual feedback, which may lag, tells me I've done enough.

Re:Unix tricks by kragen on Wednesday March 13, 2013 @11:23AM (#5369073)
It's true that M-backspace is occasionally less convenient, but it's usually more convenient.
Re:Unix tricks by cschol on Thursday March 07, 2013 @03:53PM (#5340168)
Good point. I usually don't supply the file name of the second argument. Then it would be equivalent.