Build the user commands with $BJO, after the start-up file
- The build runs $BJO, else bjo on PATH. A bjo that is not there gives a message that says what to set, and where. - An interactive bjosh runs the start-up file first, and loads the user commands after it, so the file can set PATH or BJO. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
bf961b12f9
commit
817de694b0
4 changed files with 75 additions and 27 deletions
14
src/main.bjo
14
src/main.bjo
|
|
@ -17,7 +17,9 @@
|
|||
;;
|
||||
;; - An interactive shell first runs the lines of the start-up file,
|
||||
;; $XDG_CONFIG_HOME/bjosh/rc or ~/.config/bjosh/rc.
|
||||
;; - Each bjosh loads the user's commands first, when there are any.
|
||||
;; - Each bjosh loads the user's commands, when there are any: an
|
||||
;; interactive one after the start-up file, so that the file can set PATH
|
||||
;; or BJO for the build; others before the first line.
|
||||
;; - An interactive bjosh writes the package of user commands, with an
|
||||
;; example, when its directory is not there. An empty directory there
|
||||
;; turns this off.
|
||||
|
|
@ -50,10 +52,7 @@
|
|||
;; The start-up file.
|
||||
(: (-> string))
|
||||
(defun (rc-path)
|
||||
(def config (match (getenv "XDG_CONFIG_HOME")
|
||||
((Some c) c)
|
||||
(None (path-combine (match (getenv "HOME") ((Some h) h) (None ".")) ".config"))))
|
||||
(path-combine config "bjosh/rc"))
|
||||
(path-combine (config-dir) "rc"))
|
||||
|
||||
;; The directory, with ~ for home.
|
||||
(: (-> string))
|
||||
|
|
@ -170,13 +169,14 @@
|
|||
(def path (history-path))
|
||||
(ignore (line-history-load! ed path))
|
||||
(ignore (try (directory-create (path-combine path "..")) #:catch (System.Exception)))
|
||||
(set-up-commands)
|
||||
(def sh (with-extension (make-shell jc (Some ed) ["bjosh"])))
|
||||
(def sh (make-shell jc (Some ed) ["bjosh"]))
|
||||
(def rc (rc-path))
|
||||
(when (file-exists? rc)
|
||||
(match (file-read-text rc)
|
||||
((Ok text) (ignore (run-text sh text)))
|
||||
((Err e) (shell-error (str rc ": " (fs-error-message e))))))
|
||||
(set-up-commands)
|
||||
(ignore (with-extension sh))
|
||||
(let go ()
|
||||
(report-jobs sh)
|
||||
(match (line-read ed term (prompt sh) #:notices (Some (fun () (job-changes sh))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue