Last Updated: February 20, 2016
·
1.191K
· ethanmiller

Building off of your history at the CLI

A few tricks to help you avoid too much re-typing:

~/Projects/foo$ grip 'ESTAR_' app/models.py
-bash: grip: command not found

^x^y : Replace a substring:

~/Projects/foo$ ^rip^rop
grop 'ESTAR_' app/models.py
-bash: grop: command not found

Note this is not greedy, only the first occurrence will be replaced

!!:*: Reuse all of the arguments from the previous command:

~/Projects/foo$ grep !!:*
grep 'ESTAR_' app/models.py
ESTAR_EXPORT = True

Variants here also include: !!:0 (the cmd from prev line), !!:^ (first arg from prev line), !!:2-3 (range of args from last line), and of course !! (the entire prev line)

!$: Reuse just the last argument form the previous command:

~/Projects/foo$ grep '_ESTAR' !$
grep '_ESTAR' app/models.py

fc: Finally, fc (fix command) will open the last command in your $EDITOR, and will run it when you save & quit

~/Projects/foo$ fc