Skip to content

Add ghostel ssh and ghostel ssh-install shell commands - #772

Merged
dakra merged 2 commits into
mainfrom
feat/ghostel-ssh-command
Oct 29, 2026
Merged

dakra merged 2 commits into
mainfrom
feat/ghostel-ssh-command

Conversation

@dakra

@dakra dakra commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

Explicit, ghostty +ssh-style helpers for working with remote hosts from a ghostel buffer, without turning on anything implicitly. Two commits: the first adds the commands with terminfo-only semantics, the second gives ghostel ssh per-session shell integration (revert it alone to get the terminfo-only behavior back).

  • ghostel_ssh / ghostel ssh [SSH-ARGS]: drop-in for ssh. On first contact with a host, one setup connection pushes etc/shell/ and etc/terminfo/ to ~/.local/share/ghostel/ on the remote (mirroring the repo layout) and copies the terminfo into ~/.terminfo/. The outcome is cached in ~/.cache/ghostel/ssh-terminfo-cache, keyed by target and a hash of the pushed files, so a ghostel update re-pushes. The real connection then starts the remote login shell through the pushed etc/shell/remote/login.sh, which sets the same injection environment a local spawn uses (ENV for bash, ZDOTDIR for zsh, XDG_DATA_DIRS for fish and nushell) with EMACS_GHOSTEL_PATH pointing at the pushed copy, so the existing bootstrap shims work unchanged: directory tracking into TRAMP paths, prompt marks, ghostel_cmd. No rc file on the remote is touched; plain ssh is unaffected. No tic/infocmp needed anywhere. Unknown remote login shells get a plain session with terminfo only. Pass-through for no-host, user remote commands, and the -G/-N/-O/-s/-W modes. Plain ssh is still only shadowed when ghostel-ssh-install-terminfo is on.
  • ghostel_ssh_install / ghostel ssh-install [SSH-OPTIONS] HOST: the same push plus install.sh --hook, which hooks the remote login shell persistently: a marked, idempotent block in ~/.bashrc or ~/.zshrc, a fish conf.d drop-in, or a nushell vendor-autoload file (path asked from nu, since it is platform specific). After that, plain ssh HOST loads the integration too.
  • ghostel front end with cmd, ssh, ssh-install, help (native subcommand defs in nushell).

Being shell functions rather than OSC-reachable Elisp commands, neither can be triggered by terminal output, so no allowlist entry or confirmation prompt is needed.

The README's manual remote layout moves to ~/.local/share/ghostel/etc/shell/; the TRAMP wrapper's TERMINFO_DIRS probe follows it.

Verification

  • Syntax checks on all four scripts, shellcheck on the two remote scripts, make lint, shell/environment test files (new tests for install.sh in both modes and for login.sh against a fake login shell).
  • Live against docker sshd containers with bash, zsh, fish, nushell, Alpine busybox sh (no tic) and bash with AcceptEnv INSIDE_EMACS, driven from sandboxed Emacs sessions with each local shell: integration loads, cd becomes a TRAMP default-directory, prompt lines carry ghostel-prompt, cache goes ok, plain ssh stays unhooked after ghostel ssh, ghostel ssh-install then plain ssh works, SendEnv forwarding works where sshd accepts it, Alpine gets a plain session with TERM=xterm-ghostty.
  • Known caveats, documented in the README: sshd prints no motd for ghostel ssh sessions (remote command); an OpenSSH ControlMaster opened by plain ssh cannot forward INSIDE_EMACS for later muxed sessions (the TERM gate still works); the bash hook relies on the remote profile sourcing .bashrc.

The outbound ssh terminfo wrapper becomes an always-defined
ghostel_ssh function; the ssh shadow stays behind
ghostel-ssh-install-terminfo and forwards to it.  ghostel_ssh also
offers INSIDE_EMACS via SendEnv, and its setup probe runs under
`sh -c' so a non-POSIX remote login shell (nushell) no longer turns
the probe into a parse error and a cached skip.

New ghostel_ssh_install pipes the integration scripts and compiled
terminfo over a single ssh into ~/.local/share/ghostel on the remote,
where etc/shell/remote-install.sh copies the terminfo into ~/.terminfo
and hooks the login shell: a marked block in ~/.bashrc or ~/.zshrc, a
fish conf.d drop-in, or a nushell vendor autoload file.  A ghostel
front end exposes cmd, ssh, ssh-install and help subcommands.

The documented manual remote layout moves to
~/.local/share/ghostel/shell/.
@dakra
dakra force-pushed the feat/ghostel-ssh-command branch 3 times, most recently from 411dfc5 to ab261fc Compare October 29, 2026 12:50
ghostel_ssh and ghostel_ssh_install now share one push: etc/shell and
etc/terminfo are sent to ~/.local/share/ghostel on the remote,
mirroring the repo layout, and the terminfo is copied into
~/.terminfo there.  No tic or infocmp is needed on either side, and
the cache key hashes everything pushed so an update re-pushes.

ghostel ssh then starts the remote login shell through
etc/shell/remote/login.sh, which sets the same injection environment
a local spawn uses (ENV for bash, ZDOTDIR for zsh, XDG_DATA_DIRS for
fish and nushell) with EMACS_GHOSTEL_PATH pointing at the pushed
copy, so the existing bootstrap shims work unchanged.  No rc file on
the remote is touched; plain ssh is unaffected until ghostel
ssh-install adds its hook (etc/shell/remote/install.sh --hook).
Unrecognised login shells start plainly with terminfo only.

The -G, -N, -O, -s and -W modes pass through untouched.
@dakra
dakra force-pushed the feat/ghostel-ssh-command branch from ab261fc to 29e1fa1 Compare October 29, 2026 13:50
@dakra
dakra merged commit 29e1fa1 into main Oct 29, 2026
27 checks passed
@dakra
dakra deleted the feat/ghostel-ssh-command branch October 29, 2026 13:51

This branch was previously deployed

1 inactive deployment
github-pages — 29e1fa18 Deployed Oct 29, 2026 by dakra via deploy #239
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant