3 ms·
Readline —- I’m sometimes amazed at the number of relatively seasoned developers who don’t know simple commands like ctrl-r. This one really pays off because al
by msluyter 8y ago
Readline —- I’m sometimes amazed at the number of relatively seasoned developers who don’t know simple commands like ctrl-r. This one really pays off because almost all shells and repls like ipython or the mysql client implement it.
Sample cheat sheet:
https://readline.kablamo.org/emacs.html https://readline.kablamo.org/emacs.html
You don’t have to learn it all, but mastering the basics like moving to the end/beginning on the line, moving/deleting by word, yank, history search and the like will pay off handsomely.
- hoosieree 8y agoHuge fan as well. What I really want is a terminal which has Vim's "normal mode" keybindings for scrolling back the buffer, selecting, find/replace... but then anytime you go to "insert mode", you get Readline. Best of both worlds.
- paulriddle 8y agoI think that's Neovim's terminal mode. I personally don't use it because I use a tiling window manager, so it's easy to launch another terminal wherever I want and I'm happy with the key bindings. But some people swear by terminal mode.
- hoosieree 8y agoThanks for the pointer, I'll check it out.
- todd3834 8y agoNice! I’ve been at this game for a while and ctrl-r must have slipped right past me till now. I’ve regularly do ‘history | grep ___’ but ctrl-r looks like a far better solution.
- y4mi 8y agoI'll just mention fzf then. https://github.com/junegunn/fzf https://github.com/junegunn/fzf
- twinge 8y agoIf you're a vi user, edit ~/.inputrc and add: set editing-mode vi set keymap vi-command This changes readline behavior from emacs to vi. This, along with "set -o vi" in bash, are really handy (though can be frustrating for others if you ever share a keyboard pair programming).
- Cyph0n 8y agoIn Zsh, it will set the editing mode to whatever your $EDITOR is set to. So if $EDITOR == vim, readline will be set to vim mode. I’m a vim person, but I feel like the modal workflow does not work well at all in a shell.
- ajmurmann 8y agoLots of the commands work in many macOS GUI apps as well.
- mycelium 8y agoThe origin of those shared commands isn't from readline, but rather from emacs key bindings that made it into both readline and MacOS: https://jblevins.org/log/kbd https://jblevins.org/log/kbd