- clipboard-copy: nvim's job-spawned clipboard provider process doesn't get its own controlling terminal, so /dev/tty (ENXIO) fails. Resolve the real tty from the parent (nvim)'s recorded tty via ps instead. - entrypoint.sh: chown the allocated pty to node before dropping privileges. A normal login/ssh session always does this; this entrypoint skipped it, leaving the tty root-owned so node couldn't write to it directly even after resolving the right path. - init-firewall.sh/README: allow release-assets.githubusercontent.com. GitHub release assets (e.g. mason-registry's own index) redirect here, a separate CDN from github.com's published IP ranges - without it mason can't even look up a package's install spec, regardless of PyPI access. All three verified against a rebuilt image: OSC 52 write reaches the real pty with no error, and mason's registry refresh succeeds through the firewall.
33 lines
1.6 KiB
Bash
Executable File
33 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
# Copy stdin to the system clipboard, regardless of platform or how deep in
|
|
# ssh/tmux this shell is: prefer a local clipboard tool for the current
|
|
# display server, and fall back to a single plain OSC 52 write when no local
|
|
# tool is available (e.g. a headless remote host). Any tmux hops in between
|
|
# here and the real terminal relay that onward themselves, recursively, via
|
|
# the pane-set-clipboard hook in tmux.conf -- this doesn't need to know or
|
|
# guess how many hops there are.
|
|
if command -v pbcopy >/dev/null 2>&1; then
|
|
exec pbcopy
|
|
elif [ -n "$WAYLAND_DISPLAY" ] && command -v wl-copy >/dev/null 2>&1; then
|
|
# wl-copy/xclip both hold the selection by staying alive as a background
|
|
# process (X11/Wayland selections have no central store -- the owner has
|
|
# to serve paste requests live). setsid -f detaches that process from
|
|
# our session so tmux's copy-pipe job cleanup can't kill it right after.
|
|
setsid -f wl-copy
|
|
elif [ -n "$DISPLAY" ] && command -v xclip >/dev/null 2>&1; then
|
|
setsid -f xclip -selection clipboard
|
|
else
|
|
data=$(base64 | tr -d '\n')
|
|
# /dev/tty needs this process's own session to have a controlling
|
|
# terminal, but a job spawned by nvim's clipboard provider doesn't get
|
|
# one (nvim's job-spawning doesn't establish a ctty for children).
|
|
# Resolve the real terminal from the parent's (nvim's) recorded tty
|
|
# instead, which doesn't depend on this process having its own ctty.
|
|
real_tty="/dev/$(ps -o tty= -p "$PPID" 2>/dev/null | tr -d ' ')"
|
|
if [ -w "$real_tty" ]; then
|
|
printf '\033]52;c;%s\a' "$data" > "$real_tty"
|
|
else
|
|
printf '\033]52;c;%s\a' "$data" > /dev/tty
|
|
fi
|
|
fi
|