Live data from Hacker News

How and Why to Log Your Bash History

spin.atomicobject.com

1–10 of 139 posts

Re: How and Why to Log Your Bash History

#2
Well given that we copy and paste a lot, by mistake there can be credentials and sensitive data in the bash history...

Moreover, bash history doesn't work nicely across different terminal tabs or computers.

Does anybody know a tool providing better command line history?

Re: How and Why to Log Your Bash History

#3
post #2

Well given that we copy and paste a lot, by mistake there can be credentials and sensitive data in the bash history... Moreover, bash history doesn't work nicely across different terminal tabs or computers. Does anybody know a tool providing better command line history?

For better history across different terminal (on the same computer) you may want to try zsh

Re: How and Why to Log Your Bash History

#4
This is useful if you are developing locally, but what if a lot of your command line usage is on remote servers that you have SSH'd into?

I believe iTerm2 has some support for logging remote commands, but I'm not sure it quite does the trick. Anybody know of another tool that will log both local and remote commands?

Re: How and Why to Log Your Bash History

#6
post #2

Well given that we copy and paste a lot, by mistake there can be credentials and sensitive data in the bash history... Moreover, bash history doesn't work nicely across different terminal tabs or computers. Does anybody know a tool providing better command line history?

I have a little bit of bash to save my history files and a custom search, hss, to search across them. This makes the exposure an order of degrees, if it's in bash history already then it's going to hang around longer. If I weren't doing this if still have the same problem with bash's built-in/default history.

I started this in response to a HN post some years ago.

Re: How and Why to Log Your Bash History

#7
post #2

Well given that we copy and paste a lot, by mistake there can be credentials and sensitive data in the bash history... Moreover, bash history doesn't work nicely across different terminal tabs or computers. Does anybody know a tool providing better command line history?

How about just using bash?: http://unix.stackexchange.com/a/48116

There's several controls to make the bash history do what you want. The defaults are just a bit odd.

Re: How and Why to Log Your Bash History

#9
post #4

This is useful if you are developing locally, but what if a lot of your command line usage is on remote servers that you have SSH'd into? I believe iTerm2 has some support for logging remote commands, but I'm not sure it quite does the trick. Anybody know of another tool that will log both local and remote commands?

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.

Re: How and Why to Log Your Bash History

#10
post #4

This is useful if you are developing locally, but what if a lot of your command line usage is on remote servers that you have SSH'd into? I believe iTerm2 has some support for logging remote commands, but I'm not sure it quite does the trick. Anybody know of another tool that will log both local and remote commands?

I use the built-in script command sometimes when I'm using SSH, set to write a date+server named text file to my history folder. You could do that and awk out the output lines afterwards.
Post reply on HN