Re:“I have [bash] history back to ~2003”
by leni536 on Thursday September 03, 2015 @05:25AM
(#10163972)
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.
[ Parent
| on HN ]
Re:“I have [bash] history back to ~2003”
by DEinspanjer on Thursday September 03, 2015 @10:37AM
(#10165164)
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”
by leni536 on Tuesday September 08, 2015 @05:20AM
(#10184706)
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.
Re:“I have [bash] history back to ~2003”
by anc84 on Thursday September 03, 2015 @05:42AM
(#10164018)
I would love to use this! Had to grep through ancient backup diffs way too many times to resurrect that perfect command line.
Re:“I have [bash] history back to ~2003”
by dspillett on Thursday September 03, 2015 @06:17AM
(#10164119)
I was interested myself too so had a quick search. There are a couple of implementations of the idea out there, https://code.google.com/p/advanced-shell-history/ looks the most promising of the ones I looked at. I might have to play with it later.
Re:“I have [bash] history back to ~2003”
by nyir on Thursday September 03, 2015 @05:28AM
(#10163983)
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?
Re:“I have [bash] history back to ~2003”
by leni536 on Thursday September 03, 2015 @05:38AM
(#10164008)
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, I have my regular history in place too.
Re:“I have [bash] history back to ~2003”
by caipre on Thursday September 03, 2015 @11:12AM
(#10165370)
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/