Function: ghostel--remote-term-preamble
ghostel--remote-term-preamble is a natively compiled function defined
in ghostel.el.
Signature
(ghostel--remote-term-preamble)
Documentation
Return a /bin/sh snippet that sets TERM for a remote spawn wrapper.
Designed to run *on the remote*, inside the per-spawn /bin/sh -c
wrapper, so the choice happens after TRAMP env propagation. This
sidesteps tramp-local-environment-variable-p, which strips
TERM= entries that match the local default top-level
process-environment — leaving the remote shell to inherit
TERM=dumb from TRAMP's connection shell, and disabling
readline/ZLE/fish line editing on the remote (issue #224).
When ghostel-term is the default "xterm-ghostty", the snippet:
1. Prepends ~/.local/share/ghostel/terminfo to TERMINFO_DIRS when
that directory holds the bundled entry. This lets manual
setups co-locate terminfo with the shell-integration scripts
(see README, "Option 2: Manual setup") in one place — no
tic, no touching ~/.terminfo.
2. Probes via infocmp xterm-ghostty. The probe honors all of
ncurses' standard lookup paths (the prepended dir, $TERMINFO,
~/.terminfo, $TERMINFO_DIRS, and the compiled defaults), so
it succeeds whenever the entry is reachable any way — bundled,
system-installed, or pushed via ghostel-tramp-shell-integration.
On success, advertise ghostty; on failure, fall back to
"xterm-256color" (universally available) so echo keeps working.
When ghostel-term was customized to anything else, honor it
verbatim. COLORTERM=truecolor is exported unconditionally.
Source Code
;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel--remote-term-preamble ()
"Return a `/bin/sh' snippet that sets TERM for a remote spawn wrapper.
Designed to run *on the remote*, inside the per-spawn `/bin/sh -c'
wrapper, so the choice happens after TRAMP env propagation. This
sidesteps `tramp-local-environment-variable-p', which strips
`TERM=' entries that match the local default top-level
`process-environment' — leaving the remote shell to inherit
TERM=dumb from TRAMP's connection shell, and disabling
readline/ZLE/fish line editing on the remote (issue #224).
When `ghostel-term' is the default \"xterm-ghostty\", the snippet:
1. Prepends ~/.local/share/ghostel/terminfo to TERMINFO_DIRS when
that directory holds the bundled entry. This lets manual
setups co-locate terminfo with the shell-integration scripts
(see README, \"Option 2: Manual setup\") in one place — no
`tic', no touching ~/.terminfo.
2. Probes via `infocmp xterm-ghostty'. The probe honors all of
ncurses' standard lookup paths (the prepended dir, $TERMINFO,
~/.terminfo, $TERMINFO_DIRS, and the compiled defaults), so
it succeeds whenever the entry is reachable any way — bundled,
system-installed, or pushed via `ghostel-tramp-shell-integration'.
On success, advertise ghostty; on failure, fall back to
\"xterm-256color\" (universally available) so echo keeps working.
When `ghostel-term' was customized to anything else, honor it
verbatim. `COLORTERM=truecolor' is exported unconditionally."
(cond
((equal ghostel-term "xterm-ghostty")
(concat
;; Pick up a co-located bundle if the user dropped one alongside
;; the shell integration scripts. Tilde expands in assignment
;; context per POSIX; ${TERMINFO_DIRS:+:$TERMINFO_DIRS} preserves
;; any prior search list.
"if [ -e ~/.local/share/ghostel/terminfo/x/xterm-ghostty ] "
"|| [ -e ~/.local/share/ghostel/terminfo/78/xterm-ghostty ]; "
"then export TERMINFO_DIRS=~/.local/share/ghostel/terminfo"
"${TERMINFO_DIRS:+:$TERMINFO_DIRS}; "
"fi; "
"TERM=xterm-256color; "
"if infocmp xterm-ghostty >/dev/null 2>&1; then "
"TERM=xterm-ghostty; "
"TERM_PROGRAM=ghostty; TERM_PROGRAM_VERSION=1.3.2; "
"export TERM_PROGRAM TERM_PROGRAM_VERSION; "
"fi; "
"COLORTERM=truecolor; export TERM COLORTERM; "))
(t
(concat "TERM=" (shell-quote-argument ghostel-term)
"; COLORTERM=truecolor; export TERM COLORTERM; "))))