Function: ghostel--setup-local-integration
ghostel--setup-local-integration is a natively compiled function
defined in ghostel-shell.el.
Signature
(ghostel--setup-local-integration SHELL-TYPE GHOSTEL-DIR)
Documentation
Set up shell integration for a local SHELL-TYPE spawn.
GHOSTEL-DIR is the package resource root holding etc/shell/.
Returns a plist (:env :args) for ghostel--start-process, or nil for
unrecognized shells or missing bootstrap assets. Bash's --posix
arg makes it honor ENV; the inject script then restores normal mode
with set +o posix.
Source Code
;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel-shell.el
;;; Shell-integration injection
(defun ghostel--setup-local-integration (shell-type ghostel-dir)
"Set up shell integration for a local SHELL-TYPE spawn.
GHOSTEL-DIR is the package resource root holding `etc/shell/'.
Returns a plist (:env :args) for `ghostel--start-process', or nil for
unrecognized shells or missing bootstrap assets. Bash's `--posix'
arg makes it honor ENV; the inject script then restores normal mode
with `set +o posix'."
(pcase shell-type
('bash
(let ((inject-script (expand-file-name
"etc/shell/bootstrap/bash/inject.bash"
ghostel-dir))
(env (list "GHOSTEL_BASH_INJECT=1")))
(when (file-readable-p inject-script)
(let ((old-env (getenv "ENV")))
(when old-env
(push (format "GHOSTEL_BASH_ENV=%s" old-env) env)))
(push (format "ENV=%s" inject-script) env)
(unless (getenv "HISTFILE")
(push (format "HISTFILE=%s/.bash_history"
(expand-file-name "~"))
env)
(push "GHOSTEL_BASH_UNEXPORT_HISTFILE=1" env))
(list :env env :args (list "--posix")))))
('zsh
(let ((zsh-dir (expand-file-name
"etc/shell/bootstrap/zsh" ghostel-dir)))
(when (file-directory-p zsh-dir)
(let ((env nil)
(old-zdotdir (getenv "ZDOTDIR")))
(when old-zdotdir
(push (format "GHOSTEL_ZSH_ZDOTDIR=%s" old-zdotdir) env))
(push (format "ZDOTDIR=%s" zsh-dir) env)
(list :env env)))))
;; Fish and nushell both auto-load from XDG_DATA_DIRS
((or 'fish 'nu)
(let ((integ-dir (expand-file-name
"etc/shell/bootstrap" ghostel-dir)))
(when (file-directory-p integ-dir)
(let ((xdg (or (getenv "XDG_DATA_DIRS")
"/usr/local/share:/usr/share")))
(list :env
(list
(format "XDG_DATA_DIRS=%s:%s" integ-dir xdg)
(format "GHOSTEL_SHELL_INTEGRATION_XDG_DIR=%s"
integ-dir)))))))))