When I iterate over previous commands in bash history, cursor position always jumps at the end of the command. I want some way of remembering current cursor position of last executed command.
This can be useful when trying different command line options for some command. Now I have to press up
key and move cursor backwards to where the option was typed to edit it. I want to eliminate this second step if it is possible.
I am using bash, but solutions for other shells are also interesting.
Ctrl-R
andCtrl-S
to search backwards/forward, orCtrl-A
,Ctrl-E
,Alt-F
,Alt-N
for faster movement.o=-a script.sh $o -other -options
and only change the value of $o.echo "Hello"
will printHello
afterwards you can do^Hello^World^
to replaceHello
withWorld
and now the command will beecho "World"
You can use that to switch command line options.