Live data from Hacker News

“I have [bash] history back to ~2003”

twitter.com

141–148 of 148 posts

Re: “I have [bash] history back to ~2003”

#141
post #73

$ history | wc -l 56201 I use a simple prompt_command hook to push my history (from all my machines) to a central MySQL database( https://github.com/fredsmith/history-db ). Entries are de-duped and a tally is kept so I can do simple ad-hoc reporting: mysql> select * from history order by count DESC limit 10; +-------+---------------------+-----------+----------+-------+ | id | timestamp | command | hostname | count |…

When I pipe history (to wc, grep) that is greater than 65K bytes on OS X, it hangs. Anyone else experience this or have an idea how to fix?

Re: “I have [bash] history back to ~2003”

#142
post #100

Earlier quoted context omitted.

Your shell is likely configured to write to the file, instead of appending to it. shopt -s histappend In your .bashrc should do. To have it write after every command take a look at http://unix.stackexchange.com/a/1292

Some people dislike it, but I LOVE it. I like being able to run a command, open a new terminal, and be able to control-r to find that command again. It ensures that I don't have race conditions over which terminal writes its history to disk first, as well, so I lost far fewer (zero?) history elements.

You've conflated terminal and shell there. It's an important distinction because, in fact, there's still one race condition with history files, even if you only have /one/ shell running. It's down to the Bourne Again shell not doing atomic updates when it rewrites the history file. It's one of two bugs, the other being systemd sending multiple signals in very quick succession to kill a terminal login session, that in combination cause the effect discussed at https://news.ycombinator.com/item?id=10151861 . Far from losing zero or a few history elements, it can in fact result in your losing all of your history.

Re: “I have [bash] history back to ~2003”

#144
post #73

$ history | wc -l 56201 I use a simple prompt_command hook to push my history (from all my machines) to a central MySQL database( https://github.com/fredsmith/history-db ). Entries are de-duped and a tally is kept so I can do simple ad-hoc reporting: mysql> select * from history order by count DESC limit 10; +-------+---------------------+-----------+----------+-------+ | id | timestamp | command | hostname | count |…

It seems all you do is git pull, push and check disk usage!! Do you really check disk usage almost as often as you do git pull and push? You do push and pull more than commits?!! I cant understand what is that you do if you dont use other commands like grep, find, vi, top as often?

Re: “I have [bash] history back to ~2003”

#145
post #8

I recently set up my bash history to collect into an sqlite database. Besides the exact command it records the working directory, return value, starting time, ending time, a shell and a login session id. It doesn't handle background jobs well right now though.

Do you have any links to resources you used to build it or better yet a link to your implementation? I've been pretty happy with my bash history solution, but thinking about the return value, one big thing I think would be handy would be to have a default filter for searches that removes commands that returned an error code. They might be handy to see every once in a while, but for the most part, I wouldn't want to r…

http://pastebin.com/zJkPW79C

I use bash-preexec [1] to hook on the even just before executing a command. I'm kind of nervous if my string quoting is safe though.

[1] https://github.com/rcaloras/bash-preexec

Re: “I have [bash] history back to ~2003”

#146
post #80
post #79

Earlier quoted context omitted.

I'd be quite interested in someone provided this sort of thing as a SaaS-like drop-in to Bash and Zsh if someone wants a fun weekend project..

http://shell-sink.blogspot.com/ used to provide this service - it was what I based my project on. I'll see what I can do for a hosted/SaaS system this weekend.

Any luck? :)

Re: “I have [bash] history back to ~2003”

#147
post #146
post #80

Earlier quoted context omitted.

http://shell-sink.blogspot.com/ used to provide this service - it was what I based my project on. I'll see what I can do for a hosted/SaaS system this weekend.

Any luck? :)

I started working on something myself--should have something out in a day or two :)

Re: “I have [bash] history back to ~2003”

#148
post #146

Earlier quoted context omitted.

Any luck? :)

I started working on something myself--should have something out in a day or two :)

FYI this has been a side project of mine for a while. I call it Bashhub. Check it out if you're interested! Bash history in the cloud. Indexed and searchable.

https://github.com/rcaloras/bashhub-client

https://bashhub.com

https://bashhub.com/u/rccola

Post reply on HN