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.
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"
Bind up/down to history-search-backward/history-search-forward. In ~/.inputrc
(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:
[1] https://github.com/nonsequitur/smex/