Autocomplete last command's param
$ la /foo/bar/baz/bam/long-file-name
-bash: la: command not found
$ ls /foo/bar/baz/bam/long-file-name
Ahh, that't the one!
Is this as commoner part of your workflow as mine?
Rather than retyping the filename, or having to hit up arrow, go all the way to the left, and edit your last command, why not try typing ls
then using <ESC>.
?
It will insert the last param from the previous command, saving you over 14 years of typing over the course of a typical 1000 year life time.
<ESC>.
(Escape dot), your flexible friend.
Written by Tom Lea
Related protips
4 Responses
Nice. You can also use $_ for this, as it is a short-hand for last command's parameter. Like this:
$ ls $_
I wonder how ESC + dot works in different Terminal implementations... I know that it works in the Mac Terminal but I wonder if this should be approached from the shell's perspective.
In which case $_
might be a better alternative to use.
For when you forget to run sudo on a command there's
sudo !!
And for another alternative
ls !$
where !$
is also the last "word" from the last command.
Alt+.
also works, from my experience.