https://news.ycombinator.com/item?id=10695305 ^ Here is my comment on a previous post for how I am logging all of my bash history in a logical manner (keeping track of terminals and timestamps, etc.) to an sqlite database.
I've been tempted to do something similar. The context information (e.g. environment, working directory) would be especially helpful, since that's what I'm currently missing. Have you tried https://github.com/umang1912/advanced-shell-history ? That was where I planned to start. Here are a few other projects: https://github.com/thenewwazoo/bash-history-sqlite # simple shell script to store Bash history into SQLite3 da…
How and Why to Log Your Bash History
111–120 of 139 posts
Re: How and Why to Log Your Bash History
#112I do something very similar, but without the prompt settings. I have settings in .bashrc[0] to have the history file based on date. I then use fzf[1] (fzf-tmux is great) and a grep-like tool(sift[2]) to use for ctrl-r that fuzzy-searches history and orders by usage frequency[3]. This way I can easily search for the command I'm thinking of fairly quickly. Particularly useful for those times I want to run a command aga…
Thanks for the awesome tips and simple recipe to tie things together. Had to tweak mine slightly though: ${HOSTNAME_SHORT} -> ${HOSTNAME} $HOME/Sync/Dotfiles/history -> $HOME/Sync/Dotfiles/history/* (maybe the missing star was due to HN formatting?)
sift searches a path/folder so the star you have is not needed.
But yeah, HOSTNAME_SHORT is something I derive from HOSTNAME.
Re: How and Why to Log Your Bash History
#113Re: How and Why to Log Your Bash History
#114I go one big step further than this and log everything that comes across the screen. One time it saved me from a crontab -r that wiped out a 100+ line crontab. I had viewed it recently so I just copied it out of my history. On a day to day basis it's more about looking up old queries I typed out, the results of those queries at that time, bash commands and their results, the state of a file I edited at a certain time…
This could be done using script as well.
Re: How and Why to Log Your Bash History
#115Earlier quoted context omitted.
Thanks for the awesome tips and simple recipe to tie things together. Had to tweak mine slightly though: ${HOSTNAME_SHORT} -> ${HOSTNAME} $HOME/Sync/Dotfiles/history -> $HOME/Sync/Dotfiles/history/* (maybe the missing star was due to HN formatting?)
Yes, the stars are missing, but not where you think. The --files option has a star on the inside of each quote. This makes the search only show history for the host you are on (I sync my Dotfiles between machines). sift searches a path/folder so the star you have is not needed. But yeah, HOSTNAME_SHORT is something I derive from HOSTNAME.
Re: How and Why to Log Your Bash History
#116I used to do the same thing to figure out which commands I should create short aliases for. Sounded like a good idea at the time but then I realized that I'm creating a file with an awful lot of interesting information in it and I not getting a lot in return. So I set my HISTSIZE to 1000 which is more than enough for interactive shell use and I don't have to worry about having stuff like "youtube-dl fuckmesilly.com/$…
FYI, if you want your bash history to go dark temporarily run: export HISTFILE= The rest of your session will not be logged.
Re: How and Why to Log Your Bash History
#117Earlier quoted context omitted.
Yours is a good additional idea, but it is in no way a substitute. You might want to look at some history you forgot to log. Having intentional logging on top of comprehensive logging is like markup metadata, very handy too. it makes me sad when everybody doesn't see the same things the same way. I'm just waiting now for systemd to disable bash history in favor of logging in binary form all mouse rolls intermixed wit…
6 of one, half dozen of another. It really depends on how you see things. For security reasons we've disabled logging. And users don't access servers at the shell anyway so no need for it there. We log app usage in app. I find screen logging a bit more useful than shell logging. Shell only records the commands sent and not the result. Screen records everything including interactive like nano.
That is why it is soo important to save .bash_history (seriously, that's not a dot file you should be searching hard for)
saving other things are "nice to haves"
Re: How and Why to Log Your Bash History
#118I do something very similar, but without the prompt settings. I have settings in .bashrc[0] to have the history file based on date. I then use fzf[1] (fzf-tmux is great) and a grep-like tool(sift[2]) to use for ctrl-r that fuzzy-searches history and orders by usage frequency[3]. This way I can easily search for the command I'm thinking of fairly quickly. Particularly useful for those times I want to run a command aga…
Re: How and Why to Log Your Bash History
#119Earlier quoted context omitted.
Yes, the stars are missing, but not where you think. The --files option has a star on the inside of each quote. This makes the search only show history for the host you are on (I sync my Dotfiles between machines). sift searches a path/folder so the star you have is not needed. But yeah, HOSTNAME_SHORT is something I derive from HOSTNAME.
Thanks for clarifying! Now I'm curious to hear more about how you sync your dotfiles ;-)
syncthing[0]/SyncTrazor[1]