History - Search Shortcuts
Boost your productivity in the Linux shell with quick history search commands using your arrow keys.
These shortcuts let you instantly find previously executed commands without retyping them.
Why This Matters
If you often repeat commands or tweak long terminal instructions, history search is a huge time-saver.
By enabling this feature, your Up and Down arrows can search through your history by prefix, not just by recent order.
Steps
-
Open your bash configuration file:
vi ~/.bashrc -
Add the following lines at the end of the file:
bind '"\e[A":history-search-backward' bind '"\e[B":history-search-forward' set show-all-if-ambiguous on set completion-ignore-case on -
Save the file and refresh your current shell:
source ~/.bashrc
Bonus section
-
In Powershell it is possible too, just create this file
vim %HOME%\Documents\WindowsPowerShell\profile.ps1 -
Add the following lines to the file:
Set-PSReadLineOption -HistorySearchCursorMovesToEnd Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
