7 ms·
$ 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
by fps 11y ago
$ 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 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 |
+-------+---------------------+-----------+----------+-------+
| 1 | 2015-09-02 19:41:45 | ls | xicada | 34458 |
| 89 | 2015-09-02 14:58:33 | cd .. | xicada | 4332 |
| 519 | 2015-08-24 18:38:55 | ll | xicada | 3229 |
| 9 | 2015-09-02 12:37:05 | cd | xicada | 2250 |
| 82 | 2015-08-28 18:27:07 | add | xicada | 1887 |
| 329 | 2015-08-31 18:22:49 | gs | xicada | 1817 |
| 48 | 2015-09-02 19:17:26 | git pull | xicada | 1696 |
| 275 | 2015-08-24 18:23:44 | df -h | xicada | 1529 |
| 15708 | 2013-10-08 01:33:33 | grid unn1 | Europa | 1210 |
| 44 | 2015-08-31 13:10:46 | git push | xicada | 1139 |
+-------+---------------------+-----------+----------+-------+
10 rows in set (0.02 sec)
It's pretty useful (I search through my history constantly with ctrl-R or using bash's history-search-backward hotkeys), and having a 56K line history file doesn't seem to impact history searching or shell startup any noticeable amount.
- lamby 11y agoI'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..
- fps 11y agohttp://shell-sink.blogspot.com/ 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.
- lamby 11y agoAny luck? :)
- alphast0rm 11y agoI started working on something myself--should have something out in a day or two :)
- rcaloras 11y agoFYI 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://github.com/rcaloras/bashhub-client https://bashhub.com https://bashhub.com https://bashhub.com/u/rccola https://bashhub.com/u/rccola
- michaelmior 11y agoYou could really do some interesting stuff with this. Automatically recommend aliases and show how many keystrokes you would have saved for example.
- Vexs 11y agoStuff like swiftkey automatically recommends next words, it might not be that difficult to have a similar system for a shell. Sounds like a fun idea actually. Oh, relevant XKCD. https://xkcd.com/1068/ https://xkcd.com/1068/
- nitrogen 11y agoCould be risky if the recommendations for "rm" are "-rf" and "/".
- willcodeforfoo 11y agoI've wanted this as well... plus keep track of how long commands took to run and (heck, why not?) output!
- logicallee 11y agothis must be some kind of record, in 15 words you took something great, started adding unnecessary, creeping features, and ended up with bloatware no one wants to use anymore :) Usually this takes years!
- pixelbeat 11y agoYou owe the GNU coreutils project $392 https://github.com/diafygi/gnu-pricing https://github.com/diafygi/gnu-pricing
- odonnellryan 11y agoThis is actually awesome!
- bsddb5 11y agoWhat leads you to believe OP doesn't use FreeBSD or any other Unixalike? :)
- deleted 11y ago[deleted]
- fps 11y agoI mostly do (MacOS), but: $ which ls /usr/local/opt/coreutils/libexec/gnubin/ls I'd say $392 seems like less than I should contribute.
- kbenson 11y agoWell, if it's shipped from Apple as part of their OS (I'm not sure it is from your path), then Apple would be responsible for licensing it. Which makes me wonder, does Apple have an official stance on supporting open source they use?
- TheCoelacanth 11y agoIt's not. Default ls on Mac OS X is /bin/ls.
- kbenson 11y agoI figured as much. I'm sure Apple is using some BSD version, possibly modified in-house.
- michaelmior 11y agoOn one hand this really seems like overkill. On the other hand, this is incredibly awesome. Thanks for sharing :)
- bechampion 11y agocray good man
- smellf 11y ago$ history |wc -l 82230 This is just from my work machine (~4 years old), my history is not centralized but after seeing all this I think I'm going to work it into my centralized dotfiles system. Also, I can confirm that gigantic bash histories don't affect the speed of anything. Super useful/essential tweaks - export HISTCONTROL=erasedups export HISTSIZE="NOTHING" export HISTFILESIZE="NOTHING"` shopt -s histappend export PROMPT_COMMAND='history -a;echo' erasedups will erase any earlier instance of an indentical command, keeping your history file lean. Setting HISTSIZE and HISTFILESIZE to something nonnumeric makes for no limits. histappend appends to the HISTFILE when the shell session exits. And my prompt command appends each executed command to HISTFILE immediately after it's executed. With histappend, this may be redundant. (The prompt command also gives me a blank line after each command finishes.) That mysql setup is pretty cool too, it's a rich man's $ history | awk '{print $2}' | sort | uniq -c | sort -rn | head -10 14365 vi 11006 sudo 6976 ls 6898 svn 5322 cd 3869 cdb 2809 svnvimdiff 1846 ggrep 1474 git 1285 ssh
- eevilspock 11y agoWhen 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?
- godzilla82 11y agoIt 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?