feat: use glow renderer

This commit is contained in:
ysandler
2026-02-01 18:46:18 -06:00
parent 1eae04fc60
commit d24e4f340e
4 changed files with 161 additions and 24 deletions

View File

@@ -156,7 +156,17 @@ func showResult(result *search.Result) {
}
func displayFile(filePath string, highlightLine int) {
// Try bat first for syntax highlighting
// Try glow first for Markdown rendering
if glowPath, err := exec.LookPath("glow"); err == nil {
cmd := exec.Command(glowPath, filePath)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err == nil {
return
}
}
// Fallback to bat for syntax highlighting
if batPath, err := exec.LookPath("bat"); err == nil {
args := []string{
"--paging=never",
@@ -175,7 +185,17 @@ func displayFile(filePath string, highlightLine int) {
}
}
// Fallback to plain output
// Fallback to cat
if catPath, err := exec.LookPath("cat"); err == nil {
cmd := exec.Command(catPath, filePath)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err == nil {
return
}
}
// Final fallback to plain Go file read
content, err := os.ReadFile(filePath)
if err != nil {
fmt.Fprintf(os.Stderr, "Error reading file: %v\n", err)