One thing i miss from the Linux shell is the Alt+Dot shortcut. What it does is insert the last argument of the previous command. It appears to be a trivial technique, but it's really useful.

i.e. if you type this:

$ ls /Applications/MAMP/conf/apache/

The next time you just have to type a command + shortcut and the argument will be completed for you.

$ cd 'alt+dot'

On Mac i know 2 alternatives; pressing Esc+Dot or typing !$, !* with the magic space setup.

However while both alternatives do insert the last argument(s) you've used, they can't scroll back in command history like typing Alt+Dot repeatedly does.

I can live with this options for now, but i'd love to know if someone knows a better way to do it.

link|improve this question
feedback

3 Answers

up vote 3 down vote accepted

You can press Esc-dot many times, it does the same things are alt-dot. But, like you, i find it more cumbersome to type to type than alt-dot.

link|improve this answer
I can press it many times, but it just works the first time – pablasso Dec 18 '09 at 16:00
Nevermind, you're right. You just have to release esc to press it again, Then it works as expected scrolling through history. Being that treating the option key as meta messes up some other shortcuts, this is the cleanest solution. – pablasso Dec 18 '09 at 19:22
feedback

In Terminal.app, Preferences->Settings, select the Keyboard tab. Ensure "Use Option Key as Meta" is checked.

link|improve this answer
Such a simple solution, thanks :) – pablasso Dec 18 '09 at 16:03
btw, i should mention that while this solves the alt+dot problem, it messes up another keyboard combinations like ], } or |. My keyboard (spanish) uses option+somekey to type them. Well, you can't have it all. – pablasso Dec 18 '09 at 19:09
feedback

Use option+.

Note that this is a feature of bash and not linux. Macs have bash on them as well. Alt-. is the shortcut for a builtin bash function insert-last-argument. Read the bash man page for how you can bind this to a different key combination.

link|improve this answer
Thanks, i know is a bash feature but the shortcut is not enabled by default, at least not in Terminal.app since there's no meta key by default. See Richard's answer. – pablasso Dec 18 '09 at 16:13
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.