Raimund Krämer

Software Craftsman, Consultant, Coach

No more “pressing up arrow 20 times”!

You recently ran a long shell command that you need to run again now? Like some long `git merge origin/very-long-branch-name-that-i-dont-want-to-look-up-again` or `mvn -D test -lots-of-more-options`?

Solution: Make effective use of the command history!

Step 1: Run the `history` command to list/enumerate your recently run commands.

Step 2: Run the desired command with (for example) `!126`, using the number shown in the output from step 1.

To run the last command again, simply run `!!`.

These little things can not only save time, I mainly find that they save energy and focus by reducing context switches.

(This should work in bash and most similar shells like zsh, including Git Bash on Windows.)