Hacker News new | past | comments | ask | show | jobs | submit login
The Missing Readline Primer (zwischenzugs.com)
58 points by signa11 on May 13, 2019 | hide | past | favorite | 13 comments



No mention of .inputrc? An explanation of the kill ring would be nice.

Readline is great but I've been running into something that's driven me nuts for a few weeks now. I recently switched to editing-mode=vi and it seems to have changed the behavior of unix-word-rubout(normally ctrl-w). In emacs mode, unix-word-rubout seems to append to the kill ring. In vi mode, it only replaces it. So in emacs mode, I can eat several words with 'ctrl-w' and paste them with 'ctrl-y'. In vi mode(after setting up the mappings), 'ctrl-y' only pastes the last rubbed-out word.


Your comment had enough info that I was able to Google the answer: when you switch to vi mode, C-w gets switched to vi-unix-word-rubout. Override it in .inputrc.


Sorry, I wasn't clear enough. I re-setup the mappings after enabling vi mode. So I'm still mapping C-w to unix-word-rubout and not vi-unix-word-rubout.


That was my suggestion as well :)


For those who want a wonderful update to the C-r reverse search, I highly recommend FZF[1], which allows fuzzy search of your command line history when the keybindings are enabled (among other cool features).

[1] https://github.com/junegunn/fzf


FZF + Z[1] is amazing:

[1] https://github.com/rupa/z


Reminder, if you're working on a project that you don't want to be "infected" by the GPL, take a look at anitrez' Linenoise project: https://github.com/antirez/linenoise It doesn't have all the bells and whistles as Readline, but chances are, you won't miss them anyway.


If I press Ctrl-R, start typing, and get to something like the following, how do I keep what I've typed?

(failed reverse-i-search)`ssh some-host-i-want': ssh some-host-i-dont-want

I can't figure this out!


Try control e


Nope. Ctrl-A and Ctrl-E both give the failed match (rather than what I typed). I'm not sure if there's a way to do what I want.


Ctrl-E works as far as my experience goes as well. What platform are you on? It probably comes down to your shell in this situation.


Ctrl-A and Ctrl-E are discussed. Try also Ctrl-K to delete to the end of the line. Alt-B and Alt-F to move one word at a time. I'm sure there are many more.


Very useful indeed.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: