Variable: ghostel-password-prompt-functions
ghostel-password-prompt-functions is a customizable variable defined
in ghostel.el.
Value
(ghostel--default-password-source)
Documentation
Sources tried in order to obtain a password when one is needed.
Each function is called with one argument — ROW, the trimmed text
of the cursor's row at the moment the prompt was detected, or
nil when the row text isn't available. Called inside the ghostel
buffer when ghostel--password-mode-p transitions from nil to t.
Should return a string (the password) or nil to defer to the next
function. The first non-nil return wins; ghostel sends that
string + carriage return to the subprocess and clears the wire
copy. Beware: returning an empty string "" is treated as a
hit (sudo will see it as a wrong password and re-prompt) — guard
your sources to return nil on miss; never default a miss to "".
The default ghostel--default-password-source reads with
read-passwd and so always returns (unless the user
keyboard-quits, which propagates).
To plug in auth-source (or keepass, pass, etc) prepend a function that
returns the looked-up secret on hit, nil on miss; the default acts as
the fallback. default-directory carries the TRAMP remote host when
ghostel was spawned through TRAMP, so the same handler works for sudo
on the local box and on a remote one:
(defun my-ghostel-auth-source (row)
(let* ((user (and row
(string-match
"\\\\[sudo\\\\] .+ for \\\\([^:]+\\\\):" row)
(match-string 1 row)))
(host (or (file-remote-p default-directory 'host)
(system-name))))
(and user
(auth-source-pick-first-password :host host :user user))))
(add-hook 'ghostel-password-prompt-functions #'my-ghostel-auth-source)
Source Code
;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defcustom ghostel-password-prompt-functions
'(ghostel--default-password-source)
"Sources tried in order to obtain a password when one is needed.
Each function is called with one argument — ROW, the trimmed text
of the cursor's row at the moment the prompt was detected, or
nil when the row text isn't available. Called inside the ghostel
buffer when `ghostel--password-mode-p' transitions from nil to t.
Should return a string (the password) or nil to defer to the next
function. The first non-nil return wins; ghostel sends that
string + carriage return to the subprocess and clears the wire
copy. Beware: returning an empty string \"\" is treated as a
hit (sudo will see it as a wrong password and re-prompt) — guard
your sources to return nil on miss; never default a miss to \"\".
The default `ghostel--default-password-source' reads with
`read-passwd' and so always returns (unless the user
`keyboard-quit's, which propagates).
To plug in `auth-source' (or keepass, pass, etc) prepend a function that
returns the looked-up secret on hit, nil on miss; the default acts as
the fallback. `default-directory' carries the TRAMP remote host when
ghostel was spawned through TRAMP, so the same handler works for `sudo'
on the local box and on a remote one:
(defun my-ghostel-auth-source (row)
(let* ((user (and row
(string-match
\"\\\\[sudo\\\\] .+ for \\\\([^:]+\\\\):\" row)
(match-string 1 row)))
(host (or (file-remote-p default-directory \\='host)
(system-name))))
(and user
(auth-source-pick-first-password :host host :user user))))
(add-hook \\='ghostel-password-prompt-functions #\\='my-ghostel-auth-source)"
:type 'hook)