-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Description
Currently, PromptShell's command history is stored in-memory and is lost when the user exits the session. This is unlike standard shells like bash or zsh, where users can press the up arrow to access commands from previous sessions.
This feature request proposes implementing persistent command history, so that commands are saved to a file on exit and reloaded on startup.
Proposed Solution
The readline library, which is already in use, has built-in support for this functionality. The implementation should:
- Define a history file path: The history file should be stored in the application's config directory (e.g.,
~/.config/PromptShell/history.logon Linux/macOS). - Load history on startup: When
setup_readline()is called, it should check for the existence of the history file and load it usingreadline.read_history_file(). - Save history on exit: Use the
atexitmodule to registerreadline.write_history_file()to be called automatically when the application terminates. This ensures history is saved even on unexpected exits. - Limit history size: It's good practice to set a reasonable limit on the number of commands stored using
readline.set_history_length().
Benefits
- Major Usability Improvement: Aligns PromptShell with user expectations for modern shell environments.
- Improved Workflow: Saves users from re-typing complex commands from previous sessions.
- Enhanced Productivity: Allows users to easily recall and reuse their work.
Will you make a PR?
- Yes ✅
Metadata
Metadata
Assignees
Labels
No labels