I use "yank-last-arg" most often, which is M-. by default.
$ mkdir abcd
$ cd <M-.>
On Zsh, I have M-, bound to "copy-earlier-word", which makes M-. M-, M-, cycle through the arguments to the previous command.In reading the manpage for Bash, which doesn't have this function, I've just found "history-search-backward", which searches through history to find commands based on what you've already typed. That will come in useful!
$ bind '"\er":history-search-backward'
$ bind <M-r>
(Note that M-r is bound to "revert-line" by default, but I doubt I'll use that.)These functions are all listed, with explanations, in the Bash and Zsh manpages.
Edit: As I see from another comment, a binding for "history-search-backward" to the Page Up key is in /etc/inputrc on Debian and derivatives.
if [[ $- == *i* ]]
then
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
fi
(fix: grammar)What's the point to type a half-command and then replace input line with one from history if I press up? That somewhat resembles ugly cmd.exe, which every windows user imagines when someone says 'cli'.
This is the shortcut to first learn when starting living in the command line.
Personal favorites are C-r to search back in history and C-x C-e to edit the current command line in an external editor.