ai-shell icon indicating copy to clipboard operation
ai-shell copied to clipboard

Fix issue where command history added to shell was incompatible with fish format, corrupting history

Open mooz opened this issue 9 months ago • 1 comments

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 ShellHistoryHandler interface
  • Implemented a SimpleHistoryHandler class for basic shells (bash, sh, ksh, tcsh)
  • Implemented a ZshHistoryHandler class for zsh (handling timestamp format)
  • Implemented a FishHistoryHandler class 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

mooz avatar Mar 23 '25 10:03 mooz

thanks @mooz - looks like build not passing though

steve8708 avatar Apr 03 '25 14:04 steve8708