One thing I wish I knew how to do -- presuming it's possible -- is constraining the reverse/forward history search. Say I know I'm looking for a grep command, I'll do `C-r grep`, but then I want to look through that subset of results for another string (e.g., the pattern, or maybe another part of a pipeline that I half-remember). AFAIK, reverse/forward history search is just an exact string match...and remembering ex…
Keyboard shortcuts for GNU Readline
111–120 of 174 posts
Re: Keyboard shortcuts for GNU Readline
#112Earlier quoted context omitted.
>by far the most useful shortcut for me is Ctrl-r I rarely ever use Ctrl-r since I usually know the starting part of the command I want. So, I type those starting characters and use up/down arrow keys, courtesy these lines in `~/.inputrc` "\e[A": history-search-backward "\e[B": history-search-forward
That's useful, but C-r has its merits too, as you can search for any string in the history. So, even if you run, say, python programs all day, here's a way to find that one time you used a different command line parameter... etc.
"\e[A":history-substring-search-backward
"\e[B":history-substring-search-forwardRe: Keyboard shortcuts for GNU Readline
#113"Shame, then, that even serious command line hackers never bother learning about its capabilities, as they can supercharge your command line productivity." Because it is really confusing if you are not an emacs user.
Re: Keyboard shortcuts for GNU Readline
#114I'm using bash (and thus GNU readline) all day every day at work, and by far the most useful shortcut for me is Ctrl-r (reverse history search). I also sometimes use Ctrl-a (start of line, if the keyboard doesn't have a convenient Home key) and Ctrl-e (end of line, in lieu of End key). Btw the post disses Ctrl-s / Ctrl-q for pausing/resuming terminal output, but it can be useful when you're outputting a lot of text (…
>by far the most useful shortcut for me is Ctrl-r I rarely ever use Ctrl-r since I usually know the starting part of the command I want. So, I type those starting characters and use up/down arrow keys, courtesy these lines in `~/.inputrc` "\e[A": history-search-backward "\e[B": history-search-forward
sudo systemctl restart myservice #bounce
and then ctrl-r and type your hashtag to get right to itRe: Keyboard shortcuts for GNU Readline
#115"Shame, then, that even serious command line hackers never bother learning about its capabilities, as they can supercharge your command line productivity." Because it is really confusing if you are not an emacs user.
I'm a vim guy, and I don't find the readline commands confusing. I just think of it as "Insert" mode in Vim (many of the readline commands work there too!!) and it feels pretty natural.
Re: Keyboard shortcuts for GNU Readline
#116"Shame, then, that even serious command line hackers never bother learning about its capabilities, as they can supercharge your command line productivity." Because it is really confusing if you are not an emacs user.
Re: Keyboard shortcuts for GNU Readline
#117Just enable vim mode (`set -o vi`) and call it a day.
This is actually encouraged by POSIX. set -o vi: "Allow shell command line editing using the built-in vi editor. Enabling vi mode shall disable any other command line editing mode provided as an implementation extension." No other mode, specifically emacs mode, is included in the POSIX standard. Take from this what you will. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...
Re: Keyboard shortcuts for GNU Readline
#118https://github.com/nklabs/libnklabs
("nkreadline" has editing, tab-completion (for embedded "nkcli" commands) and history)
Re: Keyboard shortcuts for GNU Readline
#119I'm using bash (and thus GNU readline) all day every day at work, and by far the most useful shortcut for me is Ctrl-r (reverse history search). I also sometimes use Ctrl-a (start of line, if the keyboard doesn't have a convenient Home key) and Ctrl-e (end of line, in lieu of End key). Btw the post disses Ctrl-s / Ctrl-q for pausing/resuming terminal output, but it can be useful when you're outputting a lot of text (…
>by far the most useful shortcut for me is Ctrl-r I rarely ever use Ctrl-r since I usually know the starting part of the command I want. So, I type those starting characters and use up/down arrow keys, courtesy these lines in `~/.inputrc` "\e[A": history-search-backward "\e[B": history-search-forward
Re: Keyboard shortcuts for GNU Readline
#120It's perhaps worth mentioning the smaller and more liberally licensed editline library if you want to embed the same line-editing functionality in your own CLI. It's been used in non-GNU Unixes for decades. https://troglobit.com/projects/editline/ See also the note at the bottom of that page about other versions of editline/libedit.