Note to my future self: A little bash trick (works in zsh too)
I'm listing the contents of a directory:
$ ls /path/dir/subdir/distdir
And want to navigate into it. Instead of retyping the whole path:
$ cd /path/dir/subdir/distdir
just use the quick substitution shortcut:
$ ^ls^cd
This replaces ls with cd in the previous command.
Source: GNU Bash Manual https://www.gnu.org/software/bash/manual/html_node/Event-Designators.html
^string1^string2^
Quick Substitution. Repeat the last command, replacing string1
with string2. Equivalent to !!:s^string1^string2^.
Source: Bash Cookbook - Quick Substitution: https://www.oreilly.com/library/view/bash-cookbook/0596526784/ch18s04.html