can Bash be configured to search string on the current input line?
For fast locating positions when using th开发者_如何学Pythone command line(Yes, I'm an Emacs fan). After viewing Bash' man, I can't find such tips. Does it need to modify readline's source code to support this?
Thank you very much!!
I don't know of a way to do it directly in the command line, but bash does support a keypress that will open the command line in your editor of choice. From the bash manpage:
edit-and-execute-command (C-xC-e)
Invoke an editor on the current command line, and execute the
result as shell commands. Bash attempts to invoke $FCEDIT,
$EDITOR, and emacs as the editor, in that order.
So hitting CTRL-x CTRL-e in emacs bindings mode (the default) or ESC v in vi bindings mode (set -o vi
for that) will open the existing command line in the editor specified by the environment variables mentioned above. You can edit the command line, and once you save and quit the editor the command will be executed.
CTRL-r (reverse-i-search) will allow you to search the current line as well as anything in your history.
If you want to jump back a couple of arguments, you can hit space, then CTRL-r again to "find again". Escape will break out of it with the cursor at the last search result.
精彩评论