elves / elvish

Powerful scripting language & versatile interactive shell
https://elv.sh/
BSD 2-Clause "Simplified" License
5.57k stars 297 forks source link

Implement history in pure elvish #126

Open xiaq opened 8 years ago

xiaq commented 8 years ago

Let's have some fun and reimplement the history subsystem of the line editor in pure elvish.

To start with, we can now expose the internal API used by edit/history.go as is, and then translate the file to elvish.

xiaq commented 7 years ago

Abandoned.

xiaq commented 7 years ago

Reopening with the new "maybe" label.

krader1961 commented 4 years ago

I just noticed this and decided to comment in light of the recent discussions about replacing the bolt DB with a different mechanism for persisting interactive command history; e.g., #596 and a discussion thread on IRC/Gitter. Start by noting that edit/history.go no longer exists.

@xiaq mentioned in the IRC/Gitter thread a preference for something like SQLite if a pure Go implementation was available. The closest thing I can find is https://godoc.org/modernc.org/ql. The problem with that solution is you couldn't use standard SQLite tools to manipulate the database. I'm not convinced that replacing one complex binary database with a different one is a meaningful change. Only if bolt is orphaned and no longer being updated would it make sense to make such a change, IMHO. The problem with bolt and SQLite is they add a lot of complexity and overhead that isn't really needed for a robust shell command history.

I still think that a text based command history file using JSON or textual protobufs is preferable. That would make the history file easy to view and edit by a human. The fish shell uses YAML which has worked well enough for that project. I'm not a fan of YAML. Too, fish uses its own decoding/encoding implementation that has some bugs. But even YAML would be preferable to the binary bolt database.

krader1961 commented 4 years ago

FWIW, There now appears to be a viable pure Go SQLite implementation: https://godoc.org/modernc.org/sqlite. There was an announcement on the golang-nuts mailing list a week ago that the project had reached beta status.

There is also https://github.com/elliotchance/c2go which has as an explicit goal supporting the correct translation of the SQLite C source to Go. In many respects this would be the ideal solution.