How do I change to the directory I just moved that file to?

If you type "!$" it will print the last argument of the previous line. Which will be the directory you moved the file into.


Try

cd !$

Try "cd" and then "[Alt] + ." (can be used repeatedly) It will scroll all your previous commands last parameter. So it will look like:

mv ./myfile /to/some/other/place/
cd <Alt>+.

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