Ctrl+R: the search that changes your life
Ctrl+R is bash history search. Seed a few commands, search backward, and stop rebuilding long lines from memory.
Ctrl+R: the search that changes your life
HOOK - 0-3s
You already typed the command. Bash kept it.
PROBLEM - 3-10s
People remember flags, hostnames, and paths badly. Then they retype a long command, miss one character, and waste another minute.
SOLUTION - 10-40s
set -o history # make sure this shell records history
history -s 'git status'; history -s 'docker ps'; history -s 'ssh root@box'
history | tail -3 # confirm the lines exist
# now press Ctrl+R, type ssh, and bash searches backward
1 git status
2 docker ps
3 ssh root@box
bash-3.2$ set -o history; history -s "git status"; history -s "docker ps"; history -s "ssh root@box"
(reverse-i-search)`ssh': ssh root@box
PAYOFF - 40-50s
Ctrl+R turns history into an index. Type a fragment, get the last matching command, hit Enter, and move on.
CTA - 50-55s
Press Ctrl+R once before you retype anything.
exit 0 #bash#terminal#productivity#linux
❯ exit 0