News for hackers. Stuff that matters.
Re:Problem solving with Unix commands by pdkl95 on Thursday February 14, 2019 @11:20AM (#19163063)
> select commands and data iteratively ... Emacs is way better in that sense

Bind up/down to history-search-backward/history-search-forward. In ~/.inputrc

    # your terminal might send something else for the
    # for the up/down keys; check with ^v<key>
    # UP
    "\e[A": history-search-backward
    # DOWN
    "\e[B": history-search-forward
(note that this affects anything that uses readline, not just bash)

The default (previous-history/next-history) only step through history one item at a time. The history-search- commands step through only the history entries that match the prefix you have already typed. (i.e. typing "cp<UP>" gets the last "cp ..." command; continuing to press <UP> steps through all of the "cp ..." commands in ${HISTFILE}). As your history file grows, this ends up kind of like smex[1] (ido-mode for M-x that prefers recently and most frequently used commands).

For maximum effect, you might want to also significantly increase the size of the saved history:

    # no file size limit
    HISTFILESIZE="-1"
    # runtime limit of commands in history. default is 500!
    HISTSIZE="1000000"
    # ignoredups to make the searching more efficient
    HISTCONTROL="ignorespace:ignoredups"
    # (and make sure HISTFILE is set to something sane)

[1] https://github.com/nonsequitur/smex/
Re:Problem solving with Unix commands by SomethingOrNot on Thursday February 14, 2019 @11:29AM (#19163147)
Both terminals, shells and Emacs suffer from the problem that you have to configure them out of their ancient defaults.
Re:Problem solving with Unix commands by gknoy on Thursday February 14, 2019 @03:53PM (#19165902)
I also like setting my history so that it appends to the history file after each command, so that they don't get clobbered when you have two shells open:

  shopt -s histappend
  export PROMPT_COMAND="history -a"