diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-01 23:05:23 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-01 23:05:51 +0300 |
| commit | 5bd21b7ed468b5ff4d1a5b2ed7e211f401eb138a (patch) | |
| tree | 672fa4625cca0ecb3e9376fc7f8e33d7b0e9deef /vendor/libghostty-vt/src/shell-integration | |
| parent | 32abb3776668ee768200019c170956f67fe33a86 (diff) | |
chore: update libghostty vendor
refs #276
Diffstat (limited to 'vendor/libghostty-vt/src/shell-integration')
6 files changed, 45 insertions, 348 deletions
diff --git a/vendor/libghostty-vt/src/shell-integration/README.md b/vendor/libghostty-vt/src/shell-integration/README.md index 590632da..07b016e6 100644 --- a/vendor/libghostty-vt/src/shell-integration/README.md +++ b/vendor/libghostty-vt/src/shell-integration/README.md @@ -61,12 +61,6 @@ if (eq $E:TERM "xterm-ghostty") { } ``` -The [Elvish](https://elv.sh) shell integration is supported by -the community and is not officially supported by Ghostty. We distribute -it for ease of access and use but do not provide support for it. -If you experience issues with the Elvish shell integration, I welcome -any contributions to fix them. Thank you! - ### Fish For [Fish](https://fishshell.com/), Ghostty prepends to the diff --git a/vendor/libghostty-vt/src/shell-integration/bash/ghostty.bash b/vendor/libghostty-vt/src/shell-integration/bash/ghostty.bash index 7eaf1397..729951ab 100644 --- a/vendor/libghostty-vt/src/shell-integration/bash/ghostty.bash +++ b/vendor/libghostty-vt/src/shell-integration/bash/ghostty.bash @@ -115,71 +115,16 @@ if [[ "$GHOSTTY_SHELL_FEATURES" == *"sudo"* && -n "$TERMINFO" ]]; then fi # SSH Integration +# +# Wrap `ssh` with `ghostty +ssh` and translate the shell-integration +# feature flags into command options. if [[ "$GHOSTTY_SHELL_FEATURES" == *ssh-* ]]; then function ssh() { - builtin local ssh_term ssh_opts - ssh_term="xterm-256color" - ssh_opts=() - - # Configure environment variables for remote session - if [[ "$GHOSTTY_SHELL_FEATURES" == *ssh-env* ]]; then - ssh_opts+=(-o "SendEnv COLORTERM TERM_PROGRAM TERM_PROGRAM_VERSION") - fi - - # Install terminfo on remote host if needed - if [[ "$GHOSTTY_SHELL_FEATURES" == *ssh-terminfo* ]]; then - builtin local ssh_user ssh_hostname - - while IFS=' ' read -r ssh_key ssh_value; do - case "$ssh_key" in - user) ssh_user="$ssh_value" ;; - hostname) ssh_hostname="$ssh_value" ;; - esac - [[ -n "$ssh_user" && -n "$ssh_hostname" ]] && break - done < <(builtin command ssh -G "$@" 2>/dev/null) - - if [[ -n "$ssh_hostname" ]]; then - builtin local ssh_target="${ssh_user}@${ssh_hostname}" - - # Check if terminfo is already cached - if "$GHOSTTY_BIN_DIR/ghostty" +ssh-cache --host="$ssh_target" >/dev/null 2>&1; then - ssh_term="xterm-ghostty" - elif builtin command -v infocmp >/dev/null 2>&1; then - builtin local ssh_terminfo ssh_cpath_dir ssh_cpath - - ssh_terminfo=$(infocmp -0 -x xterm-ghostty 2>/dev/null) - - if [[ -n "$ssh_terminfo" ]]; then - builtin echo "Setting up xterm-ghostty terminfo on $ssh_hostname..." >&2 - - ssh_cpath_dir=$(mktemp -d "/tmp/ghostty-ssh-$ssh_user.XXXXXX" 2>/dev/null) || ssh_cpath_dir="/tmp/ghostty-ssh-$ssh_user.$$" - ssh_cpath="$ssh_cpath_dir/socket" - - if builtin echo "$ssh_terminfo" | builtin command ssh -o ControlMaster=yes -o ControlPath="$ssh_cpath" -o ControlPersist=60s "$@" ' - 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 - ' 2>/dev/null; then - ssh_term="xterm-ghostty" - ssh_opts+=(-o "ControlPath=$ssh_cpath") - - # Cache successful installation - "$GHOSTTY_BIN_DIR/ghostty" +ssh-cache --add="$ssh_target" >/dev/null 2>&1 || true - else - builtin echo "Warning: Failed to install terminfo." >&2 - fi - else - builtin echo "Warning: Could not generate terminfo data." >&2 - fi - else - builtin echo "Warning: ghostty command not available for cache management." >&2 - fi - fi - fi - - # Execute SSH with TERM environment variable - TERM="$ssh_term" COLORTERM=truecolor builtin command ssh "${ssh_opts[@]}" "$@" + builtin local -a flags + flags=() + [[ "$GHOSTTY_SHELL_FEATURES" != *ssh-env* ]] && flags+=(--forward-env=false) + [[ "$GHOSTTY_SHELL_FEATURES" != *ssh-terminfo* ]] && flags+=(--terminfo=false) + "$GHOSTTY_BIN_DIR/ghostty" +ssh "${flags[@]}" -- "$@" } fi diff --git a/vendor/libghostty-vt/src/shell-integration/elvish/lib/ghostty-integration.elv b/vendor/libghostty-vt/src/shell-integration/elvish/lib/ghostty-integration.elv index 31ebf094..fc334c37 100644 --- a/vendor/libghostty-vt/src/shell-integration/elvish/lib/ghostty-integration.elv +++ b/vendor/libghostty-vt/src/shell-integration/elvish/lib/ghostty-integration.elv @@ -76,80 +76,20 @@ (external sudo) $@args } + # SSH Integration + # + # Wrap `ssh` with `ghostty +ssh` and translate the shell-integration + # feature flags into command options. fn ssh-integration {|@args| - var ssh-term = "xterm-256color" - var ssh-opts = [] - - # Configure environment variables for remote session - if (has-value $features ssh-env) { - set ssh-opts = (conj $ssh-opts ^ - -o "SendEnv COLORTERM TERM_PROGRAM TERM_PROGRAM_VERSION") + var ghostty = $E:GHOSTTY_BIN_DIR/"ghostty" + var flags = [] + if (not (has-value $features ssh-env)) { + set flags = (conj $flags --forward-env=false) } - - if (has-value $features ssh-terminfo) { - var ssh-user = "" - var ssh-hostname = "" - - # Parse ssh config - for line [((external ssh) -G $@args)] { - var parts = [(str:fields $line)] - if (> (count $parts) 1) { - var ssh-key = $parts[0] - var ssh-value = $parts[1] - if (eq $ssh-key user) { - set ssh-user = $ssh-value - } elif (eq $ssh-key hostname) { - set ssh-hostname = $ssh-value - } - if (and (not-eq $ssh-user "") (not-eq $ssh-hostname "")) { - break - } - } - } - - if (not-eq $ssh-hostname "") { - var ghostty = $E:GHOSTTY_BIN_DIR/"ghostty" - var ssh-target = $ssh-user"@"$ssh-hostname - - # Check if terminfo is already cached - if (bool ?($ghostty +ssh-cache --host=$ssh-target)) { - set ssh-term = "xterm-ghostty" - } elif (has-external infocmp) { - var ssh-terminfo = ((external infocmp) -0 -x xterm-ghostty 2>/dev/null | slurp) - - if (not-eq $ssh-terminfo "") { - echo "Setting up xterm-ghostty terminfo on "$ssh-hostname"..." >&2 - - use os - var ssh-cpath-dir = (os:temp-dir "ghostty-ssh-"$ssh-user".*") - var ssh-cpath = $ssh-cpath-dir"/socket" - - if (bool ?(echo $ssh-terminfo | (external ssh) $@ssh-opts -o ControlMaster=yes -o ControlPath=$ssh-cpath -o ControlPersist=60s $@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 - ' 2>/dev/null)) { - set ssh-term = "xterm-ghostty" - set ssh-opts = (conj $ssh-opts -o ControlPath=$ssh-cpath) - - # Cache successful installation - $ghostty +ssh-cache --add=$ssh-target >/dev/null - } else { - echo "Warning: Failed to install terminfo." >&2 - } - } else { - echo "Warning: Could not generate terminfo data." >&2 - } - } else { - echo "Warning: ghostty command not available for cache management." >&2 - } - } - } - - with [E:TERM = $ssh-term E:COLORTERM = truecolor] { - (external ssh) $@ssh-opts $@args + if (not (has-value $features ssh-terminfo)) { + set flags = (conj $flags --terminfo=false) } + $ghostty +ssh $@flags -- $@args } defer { diff --git a/vendor/libghostty-vt/src/shell-integration/fish/vendor_conf.d/ghostty-shell-integration.fish b/vendor/libghostty-vt/src/shell-integration/fish/vendor_conf.d/ghostty-shell-integration.fish index f8bfe091..e0360b5a 100644 --- a/vendor/libghostty-vt/src/shell-integration/fish/vendor_conf.d/ghostty-shell-integration.fish +++ b/vendor/libghostty-vt/src/shell-integration/fish/vendor_conf.d/ghostty-shell-integration.fish @@ -120,84 +120,17 @@ function __ghostty_setup --on-event fish_prompt -d "Setup ghostty integration" end # SSH Integration + # + # Wrap `ssh` with `ghostty +ssh` and translate the shell-integration + # feature flags into command options. set -l features (string split ',' -- "$GHOSTTY_SHELL_FEATURES") if contains ssh-env $features; or contains ssh-terminfo $features function ssh --wraps=ssh --description "SSH wrapper with Ghostty integration" set -l features (string split ',' -- "$GHOSTTY_SHELL_FEATURES") - set -l ssh_term xterm-256color - set -l ssh_opts - - # Configure environment variables for remote session - if contains ssh-env $features - set -a ssh_opts -o "SendEnv COLORTERM TERM_PROGRAM TERM_PROGRAM_VERSION" - end - - # Install terminfo on remote host if needed - if contains ssh-terminfo $features - set -l ssh_user - set -l ssh_hostname - - for line in (command ssh -G $argv 2>/dev/null) - set -l parts (string split ' ' -- $line) - if test (count $parts) -ge 2 - switch $parts[1] - case user - set ssh_user $parts[2] - case hostname - set ssh_hostname $parts[2] - end - if test -n "$ssh_user"; and test -n "$ssh_hostname" - break - end - end - end - - if test -n "$ssh_hostname" - set -l ssh_target "$ssh_user@$ssh_hostname" - - # Check if terminfo is already cached - if test -x "$GHOSTTY_BIN_DIR/ghostty"; and "$GHOSTTY_BIN_DIR/ghostty" +ssh-cache --host="$ssh_target" >/dev/null 2>&1 - set ssh_term xterm-ghostty - else if command -q infocmp - set -l ssh_terminfo - set -l ssh_cpath_dir - set -l ssh_cpath - - set ssh_terminfo "$(infocmp -0 -x xterm-ghostty 2>/dev/null)" - - if test -n "$ssh_terminfo" - echo "Setting up xterm-ghostty terminfo on $ssh_hostname..." >&2 - - set ssh_cpath_dir (mktemp -d "/tmp/ghostty-ssh-$ssh_user.XXXXXX" 2>/dev/null; or echo "/tmp/ghostty-ssh-$ssh_user."(random)) - set ssh_cpath "$ssh_cpath_dir/socket" - - if echo "$ssh_terminfo" | command ssh $ssh_opts -o ControlMaster=yes -o ControlPath="$ssh_cpath" -o ControlPersist=60s $argv ' - 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 - ' 2>/dev/null - set ssh_term xterm-ghostty - set -a ssh_opts -o "ControlPath=$ssh_cpath" - - # Cache successful installation - if test -x "$GHOSTTY_BIN_DIR/ghostty" - "$GHOSTTY_BIN_DIR/ghostty" +ssh-cache --add="$ssh_target" >/dev/null 2>&1; or true - end - else - echo "Warning: Failed to install terminfo." >&2 - end - else - echo "Warning: Could not generate terminfo data." >&2 - end - else - echo "Warning: ghostty command not available for cache management." >&2 - end - end - end - - # Execute SSH with TERM environment variable - TERM="$ssh_term" COLORTERM=truecolor command ssh $ssh_opts $argv + set -l flags + contains ssh-env $features; or set -a flags --forward-env=false + contains ssh-terminfo $features; or set -a flags --terminfo=false + "$GHOSTTY_BIN_DIR/ghostty" +ssh $flags -- $argv end end 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 diff --git a/vendor/libghostty-vt/src/shell-integration/zsh/ghostty-integration b/vendor/libghostty-vt/src/shell-integration/zsh/ghostty-integration index 76c5ce24..a96ff4bb 100644 --- a/vendor/libghostty-vt/src/shell-integration/zsh/ghostty-integration +++ b/vendor/libghostty-vt/src/shell-integration/zsh/ghostty-integration @@ -311,74 +311,15 @@ _ghostty_deferred_init() { fi # SSH Integration + # + # Wrap `ssh` with `ghostty +ssh` and translate the shell-integration + # feature flags into command options. if [[ "$GHOSTTY_SHELL_FEATURES" == *ssh-* ]]; then function ssh() { - emulate -L zsh - setopt local_options no_glob_subst - - local ssh_term ssh_opts - ssh_term="xterm-256color" - ssh_opts=() - - # Configure environment variables for remote session - if [[ "$GHOSTTY_SHELL_FEATURES" == *ssh-env* ]]; then - ssh_opts+=(-o "SendEnv COLORTERM TERM_PROGRAM TERM_PROGRAM_VERSION") - fi - - # Install terminfo on remote host if needed - if [[ "$GHOSTTY_SHELL_FEATURES" == *ssh-terminfo* ]]; then - local ssh_user ssh_hostname - - while IFS=' ' read -r ssh_key ssh_value; do - case "$ssh_key" in - user) ssh_user="$ssh_value" ;; - hostname) ssh_hostname="$ssh_value" ;; - esac - [[ -n "$ssh_user" && -n "$ssh_hostname" ]] && break - done < <(command ssh -G "$@" 2>/dev/null) - - if [[ -n "$ssh_hostname" ]]; then - local ssh_target="${ssh_user}@${ssh_hostname}" - - # Check if terminfo is already cached - if "$GHOSTTY_BIN_DIR/ghostty" +ssh-cache --host="$ssh_target" >/dev/null 2>&1; then - ssh_term="xterm-ghostty" - elif (( $+commands[infocmp] )); then - local ssh_terminfo ssh_cpath_dir ssh_cpath - - ssh_terminfo=$(infocmp -0 -x xterm-ghostty 2>/dev/null) - - if [[ -n "$ssh_terminfo" ]]; then - print "Setting up xterm-ghostty terminfo on $ssh_hostname..." >&2 - - ssh_cpath_dir=$(mktemp -d "/tmp/ghostty-ssh-$ssh_user.XXXXXX" 2>/dev/null) || ssh_cpath_dir="/tmp/ghostty-ssh-$ssh_user.$$" - ssh_cpath="$ssh_cpath_dir/socket" - - if builtin print -r "$ssh_terminfo" | command ssh "${ssh_opts[@]}" -o ControlMaster=yes -o ControlPath="$ssh_cpath" -o ControlPersist=60s "$@" ' - 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 - ' 2>/dev/null; then - ssh_term="xterm-ghostty" - ssh_opts+=(-o "ControlPath=$ssh_cpath") - - # Cache successful installation - "$GHOSTTY_BIN_DIR/ghostty" +ssh-cache --add="$ssh_target" >/dev/null 2>&1 || true - else - print "Warning: Failed to install terminfo." >&2 - fi - else - print "Warning: Could not generate terminfo data." >&2 - fi - else - print "Warning: ghostty command not available for cache management." >&2 - fi - fi - fi - - # Execute SSH with TERM environment variable - TERM="$ssh_term" COLORTERM=truecolor command ssh "${ssh_opts[@]}" "$@" + local flags=() + [[ "$GHOSTTY_SHELL_FEATURES" != *ssh-env* ]] && flags+=(--forward-env=false) + [[ "$GHOSTTY_SHELL_FEATURES" != *ssh-terminfo* ]] && flags+=(--terminfo=false) + "$GHOSTTY_BIN_DIR/ghostty" +ssh $flags -- "$@" } fi |
