On the Windows Terminal, is there a way to repeat the last command by starting character, similar to the feature on a Unix Terminal?
For example, if I type the command cd ..
then laster type !cd
on a Unix Terminal, it will do the command cd ..
again. However, I can't find this feature on the Windows Terminal.
EDIT: Here is the terminal I am using (as installed by Windows, no specific configurations):
EDIT: I am aware that pressing the up/down arrow can navigate the history of commands, but I am in a situation where I use a multitude of different commands and use the arrow keys every time can be tedious. Accessing last command by starting letter will be a lot more useful, similar to the !
command on Unix mentioned above.
Two Solutions
If you are using PowerShell or Bash on your Windows Terminal, you can use a feature called Reverse Search. This will go through your history backwards and show you the recently used command based on the starting characters.
In order to activate reverse search, press Ctrl + R on the terminal and type out the initial characters and watch the recent command appear.
Bonus tip: You can press Ctrl + shift r further to show next recent command
Note: This does not work for Command Prompt (cmd.exe
)