## Previous Command's All Arguments
mkdir long_path_here/new_dir
cd !*
## Previous Command's Last Argument
mkdir long_path_here/new_dir
cd !$
or even use $_
instead of !$
## Previous Command's First Argument
mkdir long_path_here/new_dir
cd !^
## History
mkdir long_path_here/new_dir
cd `Esc` `.`
cd `Alt`+`.`
Pressing Esc
followed by .
will give previous arguments
## "More Options"
!^ first argument
!$ last argument
!* all arguments
!:2 second argument
!:2-3 second to third arguments
!:2-$ second to last arguments
!:2* second to last arguments
!:2- second to next to last arguments
Getting Alt
to run on iTerm
- Open
Preferences
iniTerm
usingCommand
+,
- Go to
Profiles
- Go to
Keys
- Fix the setting
Left option key acts as
iTerm Preferences - How to Change Alt as Meta key
If you are Terminal on Mac, consider moving to iTerm(if you are not a power user)
- If you still want this setting in Terminal, look here
Sources
- http://askubuntu.com/questions/304830/run-a-command-with-the-argument-from-the-last-command
- http://stackoverflow.com/questions/4009412/bash-how-to-use-arguments-from-previous-command
- http://www.gnu.org/software/bash/manual/bashref.html#History-Interaction