Ask HN: Command Line History
In a past HN response to me, someone indicated that they keep a large history file for their shell. I have always set mine to not be created due to privacy concerns but this comment continues to stick with me.
For those who like to keep their command history: how much did you decide to keep and do you back it up and/or sync it?
7 comments
[ 5.3 ms ] story [ 29.7 ms ] threadMaybe it makes ctrl-r more useful. Maybe I'll find something interesting to do with this data later, but it's pretty useless. It's a sort of personal diary I might scroll through years in the future.
For privacy, you could add something like this to your .bashrc
then invoke the "forget" command to stop saving commands in that shell session, including the "forget" command you just typed but not any command before that.[0] https://stackoverflow.com/a/19533853/3064538
OTOH, I hate knowing that I have used some obscure command or combination of commands and args in the past, and not having it in my history. It was after getting fed up over one such incident a couple of years ago that I changed my history settings to unlimited. I haven't regretted it yet.
The history file is saved in my backups of home dir.
For what it's worth I sometimes am concerned with privacy, but it's important to remember that you must specify: privacy from whom?
For most cases I trust file permission flags, either only I'm root or someone else is and it wouldn't be appropriate to hide history from the sysadmin (i.e. on my employer's machines.)
- - - -
edit: TIL
> In bash 4.3 and later you can also use HISTSIZE=-1 HISTFILESIZE=-1
your disk is probably encrypted anyway, so your risk is small. just be mindful to unset HISTFILE before things like exporting secret keys during development if you're so concerned.
I like the idea of unsetting HISTFILE to a avoid saving sensative commands. That probably works on most shells.
I personally use both ksh and fish (on different machines) and keep full history on fish and no history on ksh.
Also, I use fuzzy finder for cmd+r. Absolutely love it.