Skip to content

Instantly share code, notes, and snippets.

@mfurlend
Last active October 24, 2019 21:24
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfurlend/ee6c8402e3953c02dbc2a77131fa18a8 to your computer and use it in GitHub Desktop.
Save mfurlend/ee6c8402e3953c02dbc2a77131fa18a8 to your computer and use it in GitHub Desktop.
Bash CLI re-use last line's arguments
shortcut description
!^ 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
!:0 the command
!! repeat the previous line
!:- whole line except last argument
!:s/foo/bar repeat whole line with substitution

e.g:

$        echo first second third --fourth
>> first second third --fourth
$        !:0 something-new !:3 !:2 !$ !^
>> something-new third second --fourth first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment