Rollback devenv config

This commit is contained in:
2025-06-25 22:30:54 -07:00
parent 51ccb26c4b
commit 40bfd1cdf6
3 changed files with 1 additions and 69 deletions

View File

@@ -1047,40 +1047,7 @@ any directory proffered by `consult-dir'."
(eshell/cd (substring-no-properties
(consult-dir--pick "Switch directory: ")))))
(t (eshell/cd (if regexp (eshell-find-previous-directory regexp)
(completing-read "cd: " eshell-dirs)))))))
(defun eshell/mkenv (&rest args)
"Initialize a devenv environment or configure its .envrc.
With optional argument --here or -h, forces execution in the
current directory instead of the project root."
(interactive)
(let* ((here-flag (or (member "--here" args) (member "-h" args)))
(project-root
;; Use Projectile to find the root if available, otherwise fallback to git.
(cond
((fboundp 'project-root) (project-root (project-current)))
((shell-command-to-string "git rev-parse --is-inside-work-tree")
(string-trim (shell-command-to-string "git rev-parse --show-toplevel")))))
(target-dir
(if (or here-flag (not project-root))
default-directory
project-root))
;; Localize all file operations to the target directory
(default-directory target-dir))
(if (not (file-exists-p "devenv.nix"))
;; If it doesn't exist, we assume this is a new project.
(call-process "devenv" nil 0 nil "init"))
(when (not (file-exists-p ".envrc"))
;; If .envrc is missing, create and configure it for devenv.
(with-temp-file ".envrc"
(insert "eval \"$(devenv direnvrc)\"")))
(if (file-exists-p "devenv.nix")
(find-file (expand-file-name "devenv.nix" target-dir))
(message "Could not open devenv.nix as it was not created.")))))
(completing-read "cd: " eshell-dirs))))))))
(use-package eshell
:bind (:map eshell-hist-mode-map