ai-shell
ai-shell copied to clipboard
Fix issue where command history added to shell was incompatible with fish format, corrupting history
Fix fish shell history format handling
Problem
The current implementation corrupts the fish shell history file by appending commands in an incorrect format. The fish shell history file uses a YAML-like format rather than simple newline-separated entries.
Solution
Implemented shell-specific handlers to properly read and write to each shell's history file according to its specific format.
Changes
- Created a
ShellHistoryHandlerinterface - Implemented a
SimpleHistoryHandlerclass for basic shells (bash, sh, ksh, tcsh) - Implemented a
ZshHistoryHandlerclass for zsh (handling timestamp format) - Implemented a
FishHistoryHandlerclass for fish (handling YAML-like format) - Updated main functions to use the appropriate handler based on the detected shell
Testing
- Verified history files are correctly updated after command execution in bash, zsh, and fish shells
- Specifically confirmed the fish shell history file is no longer corrupted
thanks @mooz - looks like build not passing though