Say I do:
ls somedir
is there a way I could re-run it with a different command?
Example:
ls somedir
<run same command as above but with cd instead of ls>
Say I do:
ls somedir
is there a way I could re-run it with a different command?
Example:
ls somedir
<run same command as above but with cd instead of ls>
The variable $_ is the last argument of the previous line you typed. So, for example, cd $_ would do what you described
bash-4.2$ ls X
1
bash-4.2$ cd $_
bash-4.2$ ls
1
There's also some command substitution options as well; eg ^ will replace commands on the previous line
bash-4.2$ ls X
1
bash-4.2$ ^ls^cd
cd X
bash-4.2$ ls
1
$_a lot. – Nickotine Nov 22 '23 at 03:25set -o emacsthenls <ESC>.I'm not sure there's an equivalent invimode, but I could be wrong.ls <ESC>emacs would open with thelsoutput written in? – Nickotine Nov 22 '23 at 03:51