Initial upload: shell-history-semantic-search v0.1.0
Some checks failed
CI / test (push) Has been cancelled

This commit is contained in:
2026-03-22 18:15:34 +00:00
parent a647430827
commit 94114d7dd5

View File

@@ -0,0 +1,39 @@
from pathlib import Path
from typing import Iterator
import re
from shell_history_search.parsers import HistoryEntry, HistoryParser
class BashHistoryParser(HistoryParser):
shell_type = "bash"
def get_history_path(self) -> Path:
return Path.home() / ".bash_history"
def parse(self, history_path: Path) -> Iterator[HistoryEntry]:
timestamp_pattern = re.compile(r"^#(\d{10,})$")
for line in self.read_history_file(history_path):
line = line.strip()
if not line:
continue
if line.startswith("#"):
continue
timestamp_match = timestamp_pattern.match(line)
if timestamp_match:
continue
if line.startswith(" "):
continue
entry = HistoryEntry(
command=line,
shell_type=self.shell_type,
timestamp=None,
hostname=None,
command_hash=HistoryEntry.create_hash(line),
)
yield entry