3 ms·
Missing trick: In bash, "ESC" then "." fetches the last parameter of the previous command. It's invaluable (same as typing "!$" but you get to see and edit it)
by Tepix 12y ago
Missing trick:
In bash, "ESC" then "." fetches the last parameter of the previous command. It's invaluable (same as typing "!$" but you get to see and edit it)
- akirk 12y agoYou can get any parameter of the previous command by using "Esc, <number>, Esc, .". If you repeat pressing "Esc, ." you get the n-th parameter from the command before the previous one, etc. More details in this Stackoverflow answer: http://stackoverflow.com/a/4010170/578588 http://stackoverflow.com/a/4010170/578588
- lloeki 12y agoIt's actually Meta, emulated by an ESC character by the terminal. OSX tip: check "use Option as Meta" in Terminal's preferences, and you can keep Option pressed while you mash ".".
- akirk 12y agoWhich is fine if you never need to generate characters using the Option key. For example on a German keyboard you need the Option key to write { or }.
- lloeki 12y agoI'm on a french layout so I know :-) It also has the side effect of "resurrecting" dead keys (which are unrelated to Option), making input of 'ê'and 'ï' impossible. An alternative is using iTerm2 which has a similar setting, liberally applyable to either Option key.
- Alupis 12y agoThere are some great tips/tricks in this document. Too bad it's not in Markdown or something easier on the eyes!
- grmarcil 12y agoMarkdown-ified version: http://www.notehub.org/kywfm http://www.notehub.org/kywfm Editing password is hackernews if anyone wants to tune up the markdown.
- nkouevda 12y agoYou can also use the following options to see and edit all expansions before running a command: shopt -s histverify histreedit
- BoppreH 12y agoI prefer `alt+.`, which does the same thing without having to reach for the ESC key.
- olefoo 12y agoI use `!:p` to the same effect. Which has the benefit that you can insert a history number between the bang! and the colon: ( set PS1 to include the command number if you do this a lot ).