Live data from Hacker News

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

twitter.com

91–100 of 148 posts

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

#91
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 re-run one of them.

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

#94
I keep a pretty long bash history, but I don't have it unified among machines or anything.

Others have mentioned several handy tweaks for doing this, but I didn't see all of the ones I use so I thought I'd share them here. One of the important bits is the HISTIGNORE. I am interested in commands that I might want to search for and run again one day, so I filter out commands I consider to be clutter.

  # Configure my history preferences
    # Load history substitute into readline rather than immediately executing
    shopt -s histverify histreedit
    set histappend

    # don't put duplicate lines or lines with leading spaces in the history. See bash(1) for more options
    export HISTCONTROL=ignoreboth

    export HISTIGNORE='&:bg:fg:cd*:clear:ls:pwd:history:exit:make*:* --help:'
    export HISTTIMEFORMAT="%m/%d/%y - %H:%M:%S "

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

#95
post #29

Here's something interesting - We collected bash history of around 15000 users and listed frequented used commands for fun :) http://www.webminal.org/fulc/

Doing this on my own bash_history is what prompted me to create autojump.

Thanks so much for creating autojump! autojump + Crl+R are saving me so much time that would be lost searching around.

There is just this impedance mismatch between our brains hazy recollection of things and the exactness that is required by computers. I find that fuzzy search combined with stats like most-commonly-used bridge this quite well!

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

#96
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 |…

You owe the GNU coreutils project $392 https://github.com/diafygi/gnu-pricing

What leads you to believe OP doesn't use FreeBSD or any other Unixalike? :)

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

#97

bash history had never seemed to work for me between tmux windows. Commands are 'trapped' in their respective window and the last one to close 'wins' and writes its history over the others. So I end-up with never-closing task-based window sessions and occasionally copy-paste commands to a safe file for future reference. I really should investigate the root cause some day...

Frankly the whole system is archaic. A much better system would be to have a user daemon centralize history (among other things). The benefits would be numerous: - Better performance - (optional) Sync between concurrent shells - No history overwriting problems / race conditions In addition, this daemon could be used to enable other programs such as autojump. These programs work with the current system, but are based…

It's not just the history feature that's archaic. Bash itself is quite the abomination, also operating on bytestreams is really error-prone, and then there is the whole tty system..

As much as I like my command line, I think it would be very worthwile to rethink this whole system from scratch.

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

#98
post #13
post #9

Earlier quoted context omitted.

Okay I'm curious as to why? I mean it's nice to have, but what are you going to do with the additional data later on?

It was mainly for an exercise to get familiar with sqlite. Maybe later very rarely I can use the session data (hunting down sessions where you only remember some irrelevant command). Getting the duration of some commands is useful like long running simulations, compilations. It's especially handy where you don't expect it to be too long and forget to time it beforehand. Having said that I didn't use it too much yet,…

zsh has an option to automatically print the time of commands exceeding a threshold. See here for a brief example: http://nuclearsquid.com/writings/reporttime-in-zsh/

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

#99
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..

You could really do some interesting stuff with this. Automatically recommend aliases and show how many keystrokes you would have saved for example.

Stuff 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/

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

#100

bash history had never seemed to work for me between tmux windows. Commands are 'trapped' in their respective window and the last one to close 'wins' and writes its history over the others. So I end-up with never-closing task-based window sessions and occasionally copy-paste commands to a safe file for future reference. I really should investigate the root cause some day...

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.
Post reply on HN