-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Fix GNU readline support for user input #522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix GNU readline support for user input #522
Conversation
This commit adds import for the readline module at the top of terminal_interface.py to provide GNU readline support for user input. This will allow Unix users to edit their input and browse their command history like in a UNIX shell. The readline module is imported conditionally, so the script does not break for Windows users where this module is typically not available. pyproject.toml already mentions the ability to do this when declaring the pyreadline dependency and interpreter.py also attempts importing readline, but it doesn't work unless the import is in the same module using the input function.
Hi @cowile, thank you for noticing this! I think we should drop the dependency since even the existence of the package caused problem for Windows users. Until we can more thoroughly test it across platforms, I'm not sure if we should try to add it back. What do you think? Open Interpreter had this until a few days ago -- let me know if it was beneficial to your workflow and then yes, I think a conditional import would be great. |
@KillianLucas If the pyreadline dependency is causing problems for Windows users then I agree to dropping it. I can't say pyreadline specifically has benefited my workflow as I have not attempted to use open-interpreter on Windows yet. But I will strongly argue that a line editing feature is a minimum expectation for usability. No one wants to backspace 50 times if they made a typo at the beginning of the line. The conditional import I added should definitely go in as readline is a system library on Unix-like platforms, no 3rd party dependency needed. |
Oh shit how do we do line editing? Is that a readline thing? That would be awesome. Ideally we'd have full blown editor stuff like the ability to paste in multiline strings, not sure if that's possible. I'll look into this but if you know already, let me know! |
"Line editing" is a generic term for the functionality provided by libraries like readline. Mostly it means moving around and editing the line you've typed before submitting it. readline is powerful and customizable. By default, pressing the enter key triggers the readline action accept-line, but that is configurable. You can make any other key accept-line and have the enter key type an ordinary newline character that can be edited along with the rest. See here. readline supports configuration files. Looks like python gives you |
I'd like to give a huge Not being able to easily edit the prompt and move my cursor is a constant source of frustration and this PR is a marked improvement in quality of life. There are some GIFs showing the difference in input ability in my similar PR #606 (now closed to support this PR because I didn't realize this was already proposed). |
Yeah, you're both right. I only saw the error that made me remove it on one Windows machine anyway (and not on another + any Mac or Linux system).
|
Fix GNU readline support for user input Former-commit-id: 0ea271c Former-commit-id: 2ad03e936af737d6dd3f9823a06f95e1eb0b0e19 Former-commit-id: ec0dcc4ea48e160d82b4af4aa13ea2ac614c1acd [formerly a46cc86842ae1266fd02a893f71e9fe428cc36e0] Former-commit-id: d1b064679966741ccae99b20ff6ed113303c384b
Fix GNU readline support for user input
Describe the changes you have made:
This commit adds an import for the readline module at the top of terminal_interface.py to provide GNU readline support for user input. This will allow Unix users to edit their input and browse their command history like in a UNIX shell. The readline module is imported conditionally, so the script does not break for Windows users where this module is typically not available.
pyproject.toml already mentions the ability to do this when declaring the pyreadline dependency and interpreter.py also imports readline, but it doesn't work unless the import is in the same module using the input function.
And I must credit my co-developer Open Interpreter for identifying the correct file and making the change at my direction.
Reference any relevant issue (Fixes #000)
I have tested the code on the following OS:
AI Language Model (if applicable)