Write the package of user commands on the first interactive start

When $XDG_CONFIG_HOME/bjosh/commands is not there, an interactive bjosh
writes it with the example, then builds and loads it. An empty directory
turns this off. --new-commands stays, for a start that is not interactive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Linus Björnstam 2026-12-01 10:57:19 +01:00
parent aa5bae96e0
commit bf961b12f9
4 changed files with 38 additions and 10 deletions

View file

@ -39,7 +39,8 @@
((not (file-exists? "src/main.exe")) (println "FAILURE: src/main.exe is missing: run bjo build first"))
(else
(def state (path-combine (temp-dir) (str "bjosh-interactive-" (int->string process-id))))
(ignore (directory-create (path-combine state "bjosh")))
;; An empty commands directory: no package of user commands is written.
(ignore (directory-create (path-combine state "bjosh/commands")))
(ignore (file-write-text (path-combine state "bjosh/rc") "alias fromrc='echo set in rc'\n"))
(def keys (string-join ["sleep 2.5"
"printf 'sleep 30\\r'" "sleep 1" "printf '\\032'" "sleep 0.5"