Live data from Hacker News

How and Why to Log Your Bash History

spin.atomicobject.com

71–80 of 139 posts

Re: How and Why to Log Your Bash History

#71
post #34

I 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…

How do you do this?

Session logging with this client: https://www.vandyke.com/products/securecrt/

Re: How and Why to Log Your Bash History

#72
post #21
post #19

Earlier quoted context omitted.

Work through ansible and manage your local ansible.log however you wish.

Any way I can do it with Puppet?

Do what? Puppet doesn't have a facility for running ad-hoc remote shell commands on demand. Sort of the whole point is to not do that.

Re: How and Why to Log Your Bash History

#73

Earlier quoted context omitted.

Dropping the ls, ok. But cd conveys relevant context. It would be really clever if a series of cd/ls rolled into a final absolute path cd so history shows context for the subsequent batch of commands.

If you find yourself doing a series of `cd` and `ls` commands frequently, I feel like you might be using `cd` and tab completion ineffectively. Instead of doing: ls cd foo/ ls cd bar/ ls cd baz/ You can do: ls cd foo/ bar/ baz/ This isn't what it will look like, it's just the key sequence (if this doesn't make sense let me know and I'll try to explain better). will list all the possible completions, which is equivale…

Tab autocomplete will show everything, and showing a screen full of name is not particularly useful. Most of the time I use ls it's something like "ls (asterisk)foo(asterisk)".

How do I escape asterisk on HN? :O

Re: How and Why to Log Your Bash History

#74

I 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/$…

A better solution for that problem is to not screw around with personal garbage on work computers.

Re: How and Why to Log Your Bash History

#75
post #32

I'm a big fan of saving history - trying to remember all the shell based commands we use is a nightmare! If you're using zsh, a tip I picked up from [0] was to alias all your common commands like 'cd', 'ls' 'fg'... to: ' cd' ' ls' ' fg' ... Then add the following line to your zshrc to ignore lines prepended with a space: setopt HIST_IGNORE_SPACE This keeps your history cleaner from any ls, cd, fg inputs you use. [0]…

A lot of times I want to go back and look in which directory I was executing some command.

Re: How and Why to Log Your Bash History

#76
post #73

Earlier quoted context omitted.

If you find yourself doing a series of `cd` and `ls` commands frequently, I feel like you might be using `cd` and tab completion ineffectively. Instead of doing: ls cd foo/ ls cd bar/ ls cd baz/ You can do: ls cd foo/ bar/ baz/ This isn't what it will look like, it's just the key sequence (if this doesn't make sense let me know and I'll try to explain better). will list all the possible completions, which is equivale…

Tab autocomplete will show everything, and showing a screen full of name is not particularly useful. Most of the time I use ls it's something like "ls (asterisk)foo(asterisk)". How do I escape asterisk on HN? :O

In zsh, you can complete a glob.

Re: How and Why to Log Your Bash History

#78
I also use script to log both input and output of every terminal, and the timing option to record the timing of that input and output too. Naturally stored with caution, and with a shortcut to a non-logging terminal for dealing with anything sensitive.

Re: How and Why to Log Your Bash History

#79
post #73

Earlier quoted context omitted.

If you find yourself doing a series of `cd` and `ls` commands frequently, I feel like you might be using `cd` and tab completion ineffectively. Instead of doing: ls cd foo/ ls cd bar/ ls cd baz/ You can do: ls cd foo/ bar/ baz/ This isn't what it will look like, it's just the key sequence (if this doesn't make sense let me know and I'll try to explain better). will list all the possible completions, which is equivale…

Tab autocomplete will show everything, and showing a screen full of name is not particularly useful. Most of the time I use ls it's something like "ls (asterisk)foo(asterisk)". How do I escape asterisk on HN? :O

Edit: I had a guess about how to escape asterisks here, and it didn't work!
Post reply on HN