GNU Readline is really quite a remarkable piece of technology that everyone uses and yet hardly anyone has any idea how to actually use it efficiently.
Along the same lines of the article, these things have served me well:
This one is great for just getting the quick commands to help you get around the command line more efficiently
Its sounds really dumb, but after getting to know the bash and readline man pages I have stopped using fish and zsh and just started using more vanilla bash and built in linux tools and its been fantastic. I don't feel like I have lost any productivity and my terminal is a lot more responsive.
GNU Readline, for those who doesn't know, also comes with vi mode, where you can search with '/' and '?' keys. You can enable it with 'set -o vi' in bash shell or putting 'set editing-mode vi' it in ~/.inputrc.
If you put it in ~/.inputrc, you will get vi mode in all tools/shells which are using Readline like mysql, rlwrap, psql...
If using readline in vi-mode, I recommend also setting `set show-mode-in-prompt on` to provide visual feedback on which mode you're in. Maybe it's just me, but sometimes I walk away from a repl for quite a while (weeks sometimes) and when I come back to it I stumble for a moment because it wasn't in the mode I was expecting.
Forgive me for a semi-relevant question... How do you do tab completion in a "dd" command, e.g. "dd if=MyOs_version_<TAB>..." ? The equals always suppresses the completion.
Not quite a direct answer, but you could define a shell function for "dd" which took if and of as positional arguments and passed all the rest through.
It’s quite funny and sad (no disrespect to OP or anybody) how people is still discovering what we people on fish take for granted. We can even auto-complete parameters only if we so wish. No need for any hidden setting, no need to install any additional (and usually heavy) packages. Built-in, baby.
I started using it when it was known as Ridiculous Fish, circa 2009-2010, and I've never looked back. I also learned ways of moving around the shell with Readline commands, but I cannot really attribute that to fish; I think I did that on bash/zsh as well.
I don’t have too many functions, so I cannot really say which one is really better as far as scripting goes, but with enough aliases and fish built-in functionalities, you’re pretty much set.
Exactly. I cannot answer for sure because it’s been years since last time I checked, but back then (and from comments here in previous thread, I’d say still) people was required to install extra packages to acquire such functionalities, and usually they would be a bit bloated.
This is inbuilt in fish-shell, which I highly recommend.
(I understand the functionality is inbuilt in readline, what I mean is fish exposes it in this manner by default)
IMHO fish's history + autocompletion is even better because it keeps per-directory histories. You get the most likely match in the filesystem location you currently are while typing, and then can search for other matches on the fly with the arrow keys.
There's a plugin for zsh which implements the same behaviour (this is what I'm using now):
Hmm, I've used fish for years before switching to zsh with this plugin, and I can't find any difference (although I might not have discovered every feature of fish). The 'front-end' behaviour of showing a greyed-out suggestion while typing with per-directory context, and flipping through options with arrow up/down behaves exactly the same.
I don't know about this. I use Ctrl+R a lot, and I sometimes like to be able to go up the history, then down to the command line I was writing. I probably need to try this (or a variant) out, thougt, as it boils down to muscle memory.
YMMV, but I've used both quite a bit and I find the shortcut in the article much more convenient than Ctrl-R, at least if I'm actually sure of the first characters of the command. They're not exclusive, anyway. :)
This is great. Frankly ctrl-r is almost useless. I've never had it find the command I want, because if I can remember enough of the command to find it, I can just write the whole line myself. And if it was a black magic command I'll wind up digging through log files because I won't be able to remember enough of it to find it.
It works best for me in the opposite situation: an easy-to-remember path or subcommand, as part of a long line (usually involving if or while, and a series of commands)
in addition to settings mentioned in the article, I have these two settings as well:
"\C-d": unix-filename-rubout
this allows me to delete complete filenames to the left of the cursor.. by default, you have Ctrl+w that deletes till whitespace and Esc+backspace that deletes words, but what I want most of the time is deleting filename
set echo-control-characters off
this is occasionally useful for my workflow, when I use Ctrl+c to abort currently typed command, I do not like the control character mangling the command in case I wish to copy paste that command again
This is so much better than CTRL+R that I've bound the key combo (CTRL+R/F) to this. `history | grep` suffices in those rare cases where I need the original CTRL+R behaviour.
I tried binding the arrow keys first, but it turns out I sometimes give up in the middle of writing a command in favor of reusing one from recent history, for which I need the original arrow bindings.
For a second I thought "isn't that already in bash!?" And then I realized what it does... Gosh, that's actually really useful (I wish I knew this earlier, now I need to do it in zsh).
I'm not 100% sure if it's in the default configuration or if it's something I turned on, but my zsh has the same 'search up/down based on the beginning of the line' style behavior.
Along the same lines of the article, these things have served me well:
This one is great for just getting the quick commands to help you get around the command line more efficiently
https://readline.kablamo.org/emacs.html
This one gives you all the exhaustive options around how you can tweak readline via your inputrc file
https://linux.die.net/man/3/readline
Its sounds really dumb, but after getting to know the bash and readline man pages I have stopped using fish and zsh and just started using more vanilla bash and built in linux tools and its been fantastic. I don't feel like I have lost any productivity and my terminal is a lot more responsive.