haskell / haskeline

A Haskell library for line input in command-line programs.
https://hackage.haskell.org/package/haskeline
BSD 3-Clause "New" or "Revised" License
221 stars 75 forks source link

Support flushing command history #36

Open nkartashov opened 8 years ago

nkartashov commented 8 years ago

Previously command history was only flushed after the end of a session, this commit adds flushHistory function which performs the flushing and a flag to enforce flushing after every command.

Fixes issue #5


This change is Reviewable

nkartashov commented 8 years ago

You are probably right, I'll move it to Prefs. Will modify comments to be more descriptive.

nkartashov commented 8 years ago

Sorry for not fixing such trivial problems earlier, do you like how the code looks now?

judah commented 8 years ago

One other thing you might want to think about is what the right behavior is when there's multiple sessions open at once; see for example: http://superuser.com/questions/211966/how-do-i-keep-my-bash-history-across-sessions You might want to append to the history file rather than just dumping the current session's history and overwriting everything else.

Up to you, and not necessary to do for this pull request.

lukaszlew commented 6 years ago

We should indeed append instead of overwriting. Another bash reference

414owen commented 3 years ago

~@nkartashov I've added a preferences option, and implemented append-mode writing, in this branch: https://github.com/414owen/haskeline/tree/history-flushing-tweaks You're welcome to merge those changes into this pr~

Update: see https://github.com/judah/haskeline/pull/148