Since there is no smoking gun in the Xonsh docs talking about how history backends are created and where the components of history entries come from, I decided I have to dig into the xonsh code now rather than later. The History API docs come closest, but that's cheating because those docs are autogenerated from docstrings in the Python source for xonsh. While each of these is good at doing what it says, notice that none of them discusses how history backends are instantiated or how history entries are constructed during shell execution. Tutorial: Writing Your Own History Backend - walks through authoring a new history backend with a CouchDB-backed history backend and replacing the default history backend with this new one.Tutorial: History - explains the richer model of history that xonsh offers, and introduces history command usage.I found three documents dealing with history on xon.sh: I might find learn something that I realize is undocumented, and then I can contribute that back to the project docs.The xonsh docs already include a section that tell me how to do this or something close to it.So I figured that I should read any existing documentation first, since it's possible that: I'll pay particular attention to how history backends work with the shell backend abstraction so that I can write a xontrib that is as agnostic as possible about the shell implementation in use ( ptk, ptk2, readline, jupyter, etc.). This post documents my exploration of how history is implemented in xonsh. Or some combination of the above, depending on what I find. listen to some existing hooks/events for xonsh history lookup and additions and add the functionality there.essentially step (1), but instead of adding a new history backend, augment whatever history backend is in use with this new functionlity (composition by way of monkey-patching).add a new history backend that writes entries with the additional metadata of wherever the command was executed.So I have to see where I have to collect, store, and read this metadata. I want to write my xontrib in the most xonshious (my word for if something works with the xonsh philosophy) way, so I don't want to rip this implementation scheme from per-directory-history and jam it into xonsh where there's a better way. jimhester/per-directory-history tracks this by hooking into zsh's history searching and creation commands and putting each command in two history files, a global one and one specifically for the directory the command was executed in. The piece of information that that I need to do this is missing from xonsh history entries right now: the working directory a historical command was executed in. I want to write a per-directory-history xontrib for xonsh, like the one I used for zsh. Dinogalactic - Digging into xonsh history backends dinogalactic NavigationÄigging into xonsh history backends Motivation
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |