I hate the bash history command. He never finds the story elements that I want. Sometimes I can get what I want with a story | grep XXX ', but often either the story is too long (400+ hits! yay) or too short (no hits. Boo).
I thought to myself: why didn’t I write a small “history assistant” command that allows me to basically “star” specific elements of a story and make them always appear in my story, both with a global star list and with a special star list.
That sounds amazing. So I naively tried to read the story by doing this:
system("history > blah")
FILE *fp = fopen("blah", "r")
Oh, that didn't work. Ah, I understand that the system () command runs in its own context and cannot access the bash history. Drats. So, I will try to read ~ / .bash_history
ba baaa ~ No. This allowed us to get the history before the last call of either a) history -w or b) the call to exit the shell.
So the question is: How can I programmatically access the current bash history in C?
(NB: No, not that in ~ / .bash_history, the current story, the exact result that you see when you enter the "story" from the prompt, and also why do you ask C? Why not ... but really, because I already have a convenient ncurses shell that I was going to use to allow me to get fantastic autocomplete and subnet selection history on regular terminals ...)
: , - , , , " bash".
. , "" , , . , . . . ", ", ; .:)