Earlier quoted context omitted.
Another problem for me is the ephemeral nature of many of the boxes I work on - Vagrant boxes, spot instances on AWS. I suppose I could do this and then export the bash history as part of the teardown process. At the moment, I get around this by storing as much as I can in searchable scratch files, but this relies on me knowing what to copy. I'm sure there's a better way.
Work through ansible and manage your local ansible.log however you wish.
How and Why to Log Your Bash History
21–30 of 139 posts
Re: How and Why to Log Your Bash History
#22 precmd() {
eval 'if [ "$(id -u)" -ne 0 ]; then echo "$(date "+%Y-%m-%d.%H:%M:%S") $(pwd) $(history | tail -n 1)" >>! ~/Dropbox/Logs/Bash/Macbook/bash-history-$(date "+%Y-%m-%d").log; fi'
}
I Store my logs in dropbox but you can put them whereverRe: How and Why to Log Your Bash History
#23TLDR: Overwriting history is a feature.
Re: How and Why to Log Your Bash History
#24This looks like quite a dirty hack, but I'll try it. I wish bash history wasn't so broken. I suppose once upon a time it was ok to assume people only had one shell session at a time.
As far as I can tell, bash deals with multiple shell sessions exactly how I'd expect (and want) it to: an individual terminal doesn't have access to the live session from other terminals, but when you close it it appends it's session to the shared history file, so each session ends up a continuous block in that file.
Re: How and Why to Log Your Bash History
#25Why logging to a file when you could just set the HITSIZE variable in your .bashrc ? (plus this will give you ctrl+r search which is a must)
Re: How and Why to Log Your Bash History
#26It's not obvious, but with this mechanism commands are only logged once they complete. So the log file does not include commands while they are still running. Run into that from time to time.
Re: How and Why to Log Your Bash History
#27Instead better would've been to use a custom method; internally the `require.resolve()` API can still be used to get the same semantics as `require()`
Re: How and Why to Log Your Bash History
#28export HISTFILESIZE=50000 export HISTSIZE=50000
Re: How and Why to Log Your Bash History
#29^ 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.
Re: How and Why to Log Your Bash History
#30Earlier quoted context omitted.
For better history across different terminal (on the same computer) you may want to try zsh
For better pretty much everything, one may wish to try zsh. It's pretty much a strict superset of bash, but better. There is one aspect in which it's significantly worse, though: it's fiendishly difficult to configure and understand. I just use configs provided by others, which is not ideal but works.
[1] If you are using a mac and haven't installed a newer copy of bash you're using a version that's nearing on 10 years old and does indeed mostly suck.