3 ms·
You can append to .bash_history immediately, and thus make the items available in any other open shells immediately as well. This is supported natively. Search
by milosivanovic 9y ago
You can append to .bash_history immediately, and thus make the items available in any other open shells immediately as well. This is supported natively. Search for `shopt -s histappend`.
- TorKlingberg 9y agoI want up arrow to give the last command from that shell though. I'd like Ctrl+R to search all the full history, but I don't think bash can do that combination. Also I just don't trust bash to actually keep my history, no matter what I do with HISTSIZE and HISTFILESIZE.
- gknoy 9y ago`histappend` probaby works the way you want it to. I have about a half dozen terminals open. I want to have the current shell's history seem consistent within any shell, but I want ^R in any NEW terminal to include all the commands entered in any terminal. shopt -s histappend HISTCONTROL=ignoredups:ignorespace # append to bash history Right Now export PROMPT_COMMAND="history -a" I share your distrust, though -- I've frequently lost my bash history for $REASONS (which another comment here seems to have answered :)) -- but the convenience of not having my shell history clobbered by which-shell-I-close-first is _amazing_.
- marklgr 9y ago'histappend' just makes the shell append its history list (from current session) to the history file, instead of overwriting it. This still occurs at exit time, not immediately. Besides, since you load the HISTFILE at startup, you'll append your whole history (file+session) to the HISTFILE each time you exit a shell, so either it will grow very large quickly, or you set HISTFILESIZE to limit it but as a consequence you'll lose entries (and unfortunately not the oldest). The option "only append the session entries typed in this session", while still using the whole history (file+session) for searching, is missing, as far as I know.