2 ms·
They mention history expansion, but only briefly. It is a favorite of mine. Learning the full syntax probably doesn't give good ROI these days of mice, but I th
by _TwoFinger 3y ago
They mention history expansion, but only briefly.
It is a favorite of mine.
Learning the full syntax probably doesn't give good ROI these days of mice, but I think the following shortcut notations are worth knowing:
Everything but the last argument:
% git add -p dir1
% !!- dir2
git add -p dir2
Everything but the command:
% textadept a b c
% vim !*
vim a b c
Substitute a string (once):
% echo helo world
% ^lo^llo
echo hello world
First and last arguments:
% diff path/a/file path/b/file
% diff !$ !^
diff path/b/file path/a/file
A cool detail is that even a long quoted string containing spaces is considered a single argument, and it all works fine.
Also, the bangs can be anywhere on the command line, even inside other kinds of expansion; history expansion has highest priority of all.
Edit: the above is csh-style history expansion, available in bash as well.