So lets assume I've just done:
mv ./myfile /to/some/other/place/
And I now decide I want to follow the file, and go into that directory.
Whilst I could head for the mouse, select the text, type 'cd ', then right-click to paste - I'd prefer a faster keyboard-based directory.
So, what's the best way to do that?
(In general, and if different, Centos+Bash specifically)
If you type "!$" it will print the last argument of the previous line. Which will be the directory you moved the file into.
Try
Try "cd" and then "[Alt] + ." (can be used repeatedly) It will scroll all your previous commands last parameter. So it will look like:
Esc-. (Escape followed by Period) Gives you the last argument of the previous command, it is a readline shortcut. You can type it many times to cycle through the last arguments of previous commands. Readline is a command line entry library that is used by many shells (such as bash, same maintainer), irc clients, etc.
This is probably my favorite keyboard shortcut (followed by ctrl-a for start of line and ctrl-e for end of line), give it a try ;-)
Update: Oh, katriel posted Alt-. , this is the same thing, just different a key (Alt instead of Esc)
You can also use
$_
as the last argument of the last command line