demoshell
demoshell copied to clipboard
record history and map arrow keys to navigating it
Add history saving
Maybe want a special mode to preload a set of commands into history for a specific demo?
Yes. This. I was just going to add this request. :)
HI Doug, I believe I can do this but I was wondering how you wanted to implement it. If the command is "history", then print the Demoshell history? Also, since demoshell is showing the latest command on top, we should use the "Down" arrow key to print the last command and navigate further that way right?
I think you're right that we would want a builtin command to print the history.
I hadn't given any consideration to which direction arrows should navigate in which way. I wonder if it would be confusing to the user to have that work differently from other shells? Muscle memory can be powerful.
As far as the history file format, I think I'd be happy with JSON since there's a built-in parser and it would allow us to extend the format to include multi-line commands in the future.
Just chiming in, this would be a FABULOUS addition. I failed to realize how often I hit up arrow and expect the previous command (not an unknown keypress 'up' notice.)
I discussed this with Doug at a recent OpenStack event. My suggestion would be to fundamentally rearchitect demoshell to use Pexpect (Python's version of the famous Expect). That way demoshell wouldn't have to reinvent all the interactive shell functionality we know and love; instead it would simply use a normal interactive shell and reorder the output. That would give us all the standard shell functionality we want - not just history / editing but countless other handy tricks like fancy prompts, completion, colours, aliases and so on.
This approach would also allow us to offer the other really nice set of behaviour which is currently provided by doitlive, i.e. automatic typing, since that would only intercept STDIN, whereas demoshell is only concerned with STDOUT/STDERR.
At the time neither of us could think of any reason why this approach wouldn't work, so maybe it should be the way forward.