peter@tiger:~$ ls -l Windows_20081110102654.log
-rw-r--r-- 1 peter peter 808 2008-11-10 10:26 Windows_20081110102654.log
peter@tiger:~$ cat !$
cat Windows_20081110102654.log
.....
.....
peter@tiger:~$
Then, I discovered that typing Alt-dot achieves the same result. That is, press (and hold) the Alt key, then the dot key.
There are some advantages of using Alt-dot over !$. First, you can actually see the argument immediately and interactively. You can verify that is indeed what you want, edit it if necessary, before you continue the command-line input, and eventually hit Enter to execute the command. With !$, you better have a pretty good memory.
Another advantage is that you can repeatedly type Alt-dot. The net effect is that you scroll back in command history, and display the last argument of each successive command.
After assimilating the shortcut into my command-line work habit, I found that I have been using it a lot. Give it a try!
PS Related entries from this blog:
7 comments:
Thanks for the tip - very useful
That is truly awesome. Thanks for the tip.
What they said :)
Sounds nice.. but won't work in my uxterm.
It works in Konsole, but I'm trying to avoid local access to that machine (using remote instead - ssh)
Damn, so useful, but I wasn't aware of it, I didn't wonder if such a functionality exists!
It seems you don't know this:
Add the following line to ~/.bashrc,
bind Space:magic-space
Now, whenever you press space after !$, it reveals its content. it also works for other expansions like !*, !!, !cat.
Anybody who's gonna introduce !$ or !! to his/her coworker should also mention magic-space.
Great tip, thank you.
I'm not sure about other terminals, but you can achieve the same by pressing [ESC] and then [.] in PuTTy.
Post a Comment