- Ctrl + R ---> Incremental reverse search in the command history. (Results are shown as you enter search characters).
- Ctrl + J --> Stop searching in the history and select the current command.
- Ctrl + G ---> Stop the search mode in the command history.
- Alt + P --> Non-incremental reverse search in the command history. (Does not show the result until you press Enter).
- Ctrl + _ --> Undo the last change made to the command line (e.g., to delete the last typed word or character).
- Ctrl + P / up arrow key --> Show the previous command.
- Ctrl + N / down arrow key ---> Show the next command.
- Ctrl + O ---> Execute the previous command in the history and move the cursor to the input line of the next command.
- !! ---> Execute the last entered command again.
- !* ---> It's used to reference all the arguments of the previous command. (It can be useful if you need to use the same arguments in several successive commands.)
- !*:p --> In general, in Bash, :p causes the result of the previous command to be printed instead of executed; in this case, it would print the arguments represented by !*.
- !x ---> Execute the most recent command in the history that starts with the letter x.
- !x:p ---> Print on the screen the most recent command in the history that starts with the letter x.
- !$ ---> It's used to reference the last argument of the last executed command. (For example, creating a folder and moving into it: mkdir house/door ---> cd !$)
- !^ ---> It's used to reference the first argument of the last executed command.
- !$:p ---> Print on the screen the value that !$ refers to.
- ^123^abc ---> Replace the last occurrence of "123" in the last executed command with "abc" and execute the resulting command.
- !n:m ---> Execute the command number "n" from the "m"-th argument.
- !fi ---> Execute the last command that matches the search pattern "fi".
- !n ---> Execute the nth command in the command history.
- !n:p ---> Print the nth command in the command history, without executing it.
- !n:$ ----> It's used to obtain the last argument of the nth command in the command history.
Note: If you're using Git Bash for Windows, most of these shortcuts also work.