aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/shell-integration/nushell
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/libghostty-vt/src/shell-integration/nushell')
-rw-r--r--vendor/libghostty-vt/src/shell-integration/nushell/vendor/autoload/ghostty.nu80
1 files changed, 12 insertions, 68 deletions
diff --git a/vendor/libghostty-vt/src/shell-integration/nushell/vendor/autoload/ghostty.nu b/vendor/libghostty-vt/src/shell-integration/nushell/vendor/autoload/ghostty.nu
index 17970f51..b2731f8a 100644
--- a/vendor/libghostty-vt/src/shell-integration/nushell/vendor/autoload/ghostty.nu
+++ b/vendor/libghostty-vt/src/shell-integration/nushell/vendor/autoload/ghostty.nu
@@ -4,79 +4,23 @@ export module ghostty {
$feature in ($env.GHOSTTY_SHELL_FEATURES | default "" | split row ',')
}
- # Wrap `ssh` with Ghostty TERMINFO support
+ # Wrap `ssh` with `ghostty +ssh` and translate the shell-integration
+ # feature flags into command options.
export def --wrapped ssh [...args] {
- mut ssh_env = {}
- mut ssh_opts = []
-
- # `ssh-env`: use xterm-256color and propagate COLORTERM/TERM_PROGRAM vars
- if (has_feature "ssh-env") {
- $ssh_env.TERM = "xterm-256color"
- $ssh_env.COLORTERM = "truecolor"
- $ssh_opts = [
- "-o" "SendEnv COLORTERM TERM_PROGRAM TERM_PROGRAM_VERSION"
- ]
+ if not ((has_feature "ssh-env") or (has_feature "ssh-terminfo")) {
+ ^ssh ...$args
+ return
}
- # `ssh-terminfo`: auto-install xterm-ghostty terminfo on remote hosts
- if (has_feature "ssh-terminfo") {
- let ghostty = ($env.GHOSTTY_BIN_DIR? | default "") | path join "ghostty"
-
- let ssh_cfg = ^ssh -G ...$args
- | lines
- | parse "{key} {value}"
- | where key in ["user" "hostname"]
- | select key value
- | transpose -rd
- | default {user: $env.USER hostname: "localhost"}
- let ssh_id = $"($ssh_cfg.user)@($ssh_cfg.hostname)"
-
- if (^$ghostty "+ssh-cache" $"--host=($ssh_id)" | complete | $in.exit_code == 0) {
- $ssh_env.TERM = "xterm-ghostty"
- } else {
- $ssh_env.TERM = "xterm-256color"
-
- let terminfo = try {
- ^infocmp -0 -x xterm-ghostty
- } catch {
- print -e "infocmp failed, using xterm-256color"
- }
-
- if ($terminfo | is-not-empty) {
- print $"Setting up xterm-ghostty terminfo on ($ssh_cfg.hostname)..."
-
- let ctrl_path = (
- mktemp -td $"ghostty-ssh-($ssh_cfg.user).XXXXXX"
- | path join "socket"
- )
-
- let remote_args = $ssh_opts ++ [
- "-o" "ControlMaster=yes"
- "-o" $"ControlPath=($ctrl_path)"
- "-o" "ControlPersist=60s"
- ] ++ $args
-
- $terminfo | ^ssh ...$remote_args '
- infocmp xterm-ghostty >/dev/null 2>&1 && exit 0
- command -v tic >/dev/null 2>&1 || exit 1
- mkdir -p ~/.terminfo 2>/dev/null && tic -x - 2>/dev/null && exit 0
- exit 1'
- | complete
- | if $in.exit_code == 0 {
- ^$ghostty "+ssh-cache" $"--add=($ssh_id)" e>| print -e
- $ssh_env.TERM = "xterm-ghostty"
- $ssh_opts = ($ssh_opts ++ ["-o" $"ControlPath=($ctrl_path)"])
- } else {
- print -e "terminfo install failed, using xterm-256color"
- }
- }
- }
+ let ghostty = ($env.GHOSTTY_BIN_DIR? | default "") | path join "ghostty"
+ mut flags = []
+ if not (has_feature "ssh-env") {
+ $flags = ($flags ++ ["--forward-env=false"])
}
-
- let ssh_args = $ssh_opts ++ $args
- with-env $ssh_env {
- ^ssh ...$ssh_args
+ if not (has_feature "ssh-terminfo") {
+ $flags = ($flags ++ ["--terminfo=false"])
}
+ ^$ghostty "+ssh" ...$flags "--" ...$args
}
# Wrap `sudo` to preserve Ghostty's TERMINFO environment variable