News for hackers. Stuff that matters.
Re:Know Your Tools – Terminal and Bash by endur on Friday March 13, 2015 @03:10PM (#9199271)
I really like '!$' and '!:1' in bash. '!$' holds the last argument of the last command and '!:n' holds the nth argument.

$ cd /big/long/path/to/this.txt Oops $ vim !$

Re:Know Your Tools – Terminal and Bash by DougMerritt on Friday March 13, 2015 @05:16PM (#9200107)
It should be noted for onlookers that this is the abbreviated form; !-3:4 goes back to the third-to-last command and refers to its fourth argument, and similarly !-3:$ is its last argument.

It's also apparently not universally known that bash has csh-style (similar to sed) editing, so "s^foo^bar" will repeat the previous command with "bar" substituted at for bar. So "ls foo" becomes "ls bar".

Similarly with !-3:s^foo^bar

I freely mix these things with readline-editing, depending on what needs to be done.

Since csh gets a lot of disrespect these days, to give credit where due: these are all Bill Joy features from the original csh -- it's a good thing that bash borrowed innovations from various shells beyond Bourne shell and ksh.

Historical footnote: We donated code to him to do readline-style editing circa 1978, but he said raw mode was bogging down the pdp 11 too much. Systems were a bit slower back then.

Re:Know Your Tools – Terminal and Bash by 458QxfC2z3 on Friday March 13, 2015 @03:31PM (#9199433)
If using readline (emacs) keybindings, press Alt and period for the same effect as !$.