soveran / clac

Command-line, stack-based calculator with postfix notation
BSD 2-Clause "Simplified" License
356 stars 30 forks source link

Add history persistence to file #23

Open tobia opened 4 years ago

tobia commented 4 years ago

Hey there. Thank you for this great tool. I added history saving and loading to file (~/.local/share/clac/history, configurable with XDG env) because I often need to review or amend previous calculations, so I guess other people would find it useful too. Besides, I didn't do much, because Linenoise already has the required functions.

tobia commented 4 years ago

I didn't handle the mkdir return value because there's not much we can do, the app should just ignore any error condition on that directory. If Linenoise can save its history there, it will do so, otherwise it won't.

As for the imports, I copied them from man 2 mkdir