From fef67c76ea5177b767204cda75dbc4205dad8073 Mon Sep 17 00:00:00 2001
From: Kevin Lyda <kevin@lyda.ie>
Date: Fri, 16 May 2025 07:42:37 +0100
Subject: [PATCH] Fix history file

---
 repl/repl.go | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/repl/repl.go b/repl/repl.go
index 3bb6eb2..88173b2 100644
--- a/repl/repl.go
+++ b/repl/repl.go
@@ -3,6 +3,7 @@ package repl
 
 import (
 	"fmt"
+	"os"
 	"path"
 	"unicode"
 
@@ -13,12 +14,13 @@ import (
 
 // Loop is the main event loop.
 func Loop() error {
-	// fmt.Printf("TODO: get config for user %s using xdg.\n", user)
+	histdir := path.Join(xdg.ConfigHome, "BULLETIN")
+	os.MkdirAll(histdir, 0700)
+	histfile := path.Join(histdir, fmt.Sprintf("%s.history", this.User.Login))
 	rl, err := readline.NewEx(
 		&readline.Config{
-			Prompt: "BULLETIN> ",
-			HistoryFile: path.Join(xdg.ConfigHome, "BULLETIN",
-				fmt.Sprintf("%s.history", this.User.Login)),
+			Prompt:      "BULLETIN> ",
+			HistoryFile: histfile,
 			// TODO: AutoComplete:    completer,
 			InterruptPrompt:   "^C",
 			EOFPrompt:         "EXIT",
-- 
GitLab