4 ms·
A usage pattern with !$ is: % mkdir foo % chmod g+s !$ % ls -ld !$ # (make sure it's correct) % cd !$
by mturmon 14y ago
A usage pattern with !$ is:
% mkdir foo
% chmod g+s !$
% ls -ld !$ # (make sure it's correct)
% cd !$
- jdf 14y agoAlternatively, you can add ':p' to the third line. This will print out the command rather than executing it. Additionally, it's also added to your bash history, so you can add it by pressing the up arrow. $ chmod 755 foo $ cd !$:p cd foo $ cd foo There are some similar "tricks" here: https://news.ycombinator.com/item?id=5337558 https://news.ycombinator.com/item?id=5337558
- mturmon 14y agoI have found "magic-space" more useful than ":p". This auto-expands history substitutions (like !$) when you press the space bar. You can bind it to the space key in tcsh or bash. It also works for !!, !vi, and other substitutions. So, when you press ! $ <space>, it expands out to "foo" in place, so you can be sure that's what you wanted, and edit it in place. I think :p predates magic-space. They're both decades old at this point though.