News for hackers. Stuff that matters.
Re:What typing ^D does on Unix (2009) by Pete_D on Tuesday September 06, 2016 @03:28PM (#12438631)
There's a lot of unexpected gems in the readline defaults. I recommend people try paging through "bind -p" in bash some time to see what's there.

Personal favorites are C-r to search back in history and C-x C-e to edit the current command line in an external editor.

Re:What typing ^D does on Unix (2009) by Symbiote on Tuesday September 06, 2016 @04:27PM (#12439064)
Emacs users will recognize many of the readline defaults -- unsurprisingly, given both are GNU software.

I use "yank-last-arg" most often, which is M-. by default.

  $ mkdir abcd
  $ cd <M-.>
On Zsh, I have M-, bound to "copy-earlier-word", which makes M-. M-, M-, cycle through the arguments to the previous command.

In reading the manpage for Bash, which doesn't have this function, I've just found "history-search-backward", which searches through history to find commands based on what you've already typed. That will come in useful!

  $ bind '"\er":history-search-backward'
  $ bind <M-r>
(Note that M-r is bound to "revert-line" by default, but I doubt I'll use that.)

These functions are all listed, with explanations, in the Bash and Zsh manpages.

Edit: As I see from another comment, a binding for "history-search-backward" to the Page Up key is in /etc/inputrc on Debian and derivatives.

Re:What typing ^D does on Unix (2009) by wruza on Tuesday September 06, 2016 @03:54PM (#12438816)
It is also very convenient to remap up/down keys to not just list history, but to do completion based on already typed characters:

    if [[ $- == *i* ]]
    then
        bind '"\e[A": history-search-backward'
        bind '"\e[B": history-search-forward'
    fi
(fix: grammar)
Re:What typing ^D does on Unix (2009) by nitrogen on Tuesday September 06, 2016 @04:10PM (#12438946)
Debian and Ubuntu typically have a commented-out mapping for this in /etc/inputrc as pgup/pgdn that I always enable in my ~/.inputrc. Editline supports something similar in .editrc IIRC.
Re:What typing ^D does on Unix (2009) by wruza on Tuesday September 06, 2016 @07:10PM (#12439913)
Funny, I became FreeBSD user because default .cshrc contained it (iirc). I didn't know about shells, readline, etc. back then. Wonder why they do not enable it on up-down by default, cause I see too many linuxoids around bored with up-up-up-enter up-up-up-enter to replay history, not even knowing that completion exists (along with at least ^K ^U ^C).

What's the point to type a half-command and then replace input line with one from history if I press up? That somewhat resembles ugly cmd.exe, which every windows user imagines when someone says 'cli'.

Re:What typing ^D does on Unix (2009) by Sharlin on Tuesday September 06, 2016 @04:41PM (#12439137)
Weird, I'd have thought C-r is the one readline command everybody knows even if they know nothing else abour readline. Almost cannot imagine using command line without it. (Though there's also the "like tab-complete but from history" that I never really learned to use.)
Re:What typing ^D does on Unix (2009) by grive on Tuesday September 06, 2016 @05:13PM (#12439331)
Ah! yes, at this point C-r is so entrenched in my habit, I didnt even realize it might be new to some.

This is the shortcut to first learn when starting living in the command line.

Re:What typing ^D does on Unix (2009) by pixelbeat on Wednesday September 07, 2016 @05:36AM (#12441910)
Yes some of these useful functions should be bound by default IMHO. Here are my settings to bind ctrl-{left,right} and {up,down} to more useful defaults. I.E. jump as the shell tokenizes the line, and search history for what's already typed respectively