4 ms·
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
by ralph 14y ago
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
- cschol 14y agoGood point. I usually don't supply the file name of the second argument. Then it would be equivalent.
- kragen 14y agoSo 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.
- ralph 14y agoYou'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.
- kragen 14y agoIt's true that M-backspace is occasionally less convenient, but it's usually more convenient.