summaryrefslogtreecommitdiff
path: root/src/shell-integration
AgeCommit message (Collapse)Author
2025-10-01shell-integration: append $GHOSTTY_BIN_DIR to $PATHJon Parise
For consistency with the termio/Exec.zig implementation, we always append to the PATH (lowest priority).
2025-10-01shell-integration: remove redundant commentsJon Parise
I think the conditions are sufficiently self-descriptive.
2025-09-30fix: cleaned up elvish and fish integrations for bin_dirMatthew Hrehirchuk
2025-09-30feat: add GHOSTTY_BIN_DIR to path via shell integrationMatthew Hrehirchuk
2025-09-15mark ssh shell-integration wrapper as a function this matches other features ↵rhodes-b
+ fixes a case where users alias to some other command
2025-08-19zsh: clarify that an unset ZDOTDIR defaults to HOMEJon Parise
This fixes the incorrect comment and uses $HOME (rather than ~) to be a little bit more explicit. Also, our script is named ghostty-integration, not ghostty.zsh, so update that part of the comment, too.
2025-08-19zsh: unset _ghostty_file in the early exit pathJon Parise
If we're running a too-old version of zsh, we exit early. This skipped the _ghostty_file cleanup path below.
2025-08-04fix fish shell syntax for ssh-env shell integrationRobbie Vanbrabant
As discussed here https://github.com/ghostty-org/ghostty/discussions/8021 This fixes invalid fish shell syntax. As an example, run ghostty like so: `XDG_CONFIG_HOME=/tmp ghostty --shell-integration-features=ssh-env --command="/usr/bin/env fish"`. Setting XDG_CONFIG_HOME to /tmp is just to start from the default config. Before: ``` Welcome to fish, the friendly interactive shell Type help for instructions on how to use fish robbiev@neo ~/s/ghostty (fish-shell-ssh)> ssh git@github.com env: ‘command’: No such file or directory robbiev@neo ~/s/ghostty (fish-shell-ssh) [127]> ``` After: ``` Welcome to fish, the friendly interactive shell Type help for instructions on how to use fish robbiev@neo ~/s/ghostty (fish-shell-ssh)> ssh git@github.com PTY allocation request failed on channel 0 Hi robbiev! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed. robbiev@neo ~/s/ghostty (fish-shell-ssh) [1]> ``` My understanding of the fix follows. The script is using `command` to make sure it calls the actual ssh binary and not some intermediate shell function with the same name (`man command` explains). `env` can be useful for fish compat < 3.1, where [the KEY=value syntax was introduced](https://fishshell.com/docs/current/faq.html#how-do-i-set-or-clear-an-environment-variable). However because `command` is a builtin it doesn't work in this case. So a simple solution is this, requiring fish >= 3.1 ``` TERM="$ssh_term" command ssh $ssh_opts $argv ``` An [alternative](https://serverfault.com/questions/164305/how-can-i-set-environment-variable-for-just-one-command-in-fish-shell) for maximum fish compat could be the following: ``` begin set -lx TERM "$ssh_term" command ssh $ssh_opts $argv end ``` According to `man set`, `-l` means local to the block and `-x` means export. I'm in favour of keeping `command` as it makes the integration more predicable. The reason I went with the current fix: - It's easier to understand without knowing fish shell. - [kat found that fish 3.1 should be widely available](https://github.com/ghostty-org/ghostty/discussions/8021#discussioncomment-13877129).
2025-08-03bash: upgrade to bash-preexec 0.6.0Jon Parise
https://github.com/rcaloras/bash-preexec/releases/tag/0.6.0 This is a small update for us because we've been using a patched version of this script in Ghostty for some time, and the 0.6.0 release includes most of the local changes we made as part of maintaining and improving our bash shell integration. - https://github.com/rcaloras/bash-preexec/pull/167 - https://github.com/rcaloras/bash-preexec/pull/170 We continue to maintain one local HISTCONTROL-related modification (#2478). There are a few upstream conversations related to HISTCONTROL that might eliminate the need for this local patch, so we may revisit that in the future.
2025-07-19Remove unnecessary stderr redirection in fish integrationHuaDeity
2025-07-19Fix shell variable expansion in fish SSH setupHuaDeity
2025-07-16shell-integration.fish: don't use $ssh_terminfoHuaDeity
2025-07-10bash: preserve an existing ENV valueJon Parise
Our bash shell integration code uses ENV (in POSIX mode) to bootstrap our shell integration script. This had the side effect of overwriting an existing ENV value. This change preserves ENV by storing it temporarily in GHOSTTY_BASH_ENV. Note that this doesn't enable --posix mode support for automatic shell integration. (--posix does work; we just skip shell integration when that flag is specified.) We can reconsider implementing full --posix support separately.
2025-07-09elvish: revise the ssh integrationJon Parise
The previous implementation wasn't quite working. This revision reworks it in a few ways: - Fix various syntax issues - Redirect the `ssh` command to our 'ssh-integration' function - Locate the `ghostty` binary using $GHOSTTY_BIN_DIR - Use os:temp-dir to create our temporary directory Also, consistently use 2-space indents, which is the Elvish standard.
2025-07-09shell-integration: use $GHOSTTY_BIN_DIR/ghosttyJon Parise
Locate our ghostty binary using $GHOSTTY_BIN_DIR rather than searching the PATH.
2025-07-09shell-integration: simplify "ssh target" checksJon Parise
This value is always set to a non-empty string, and we only need this value after we've determined that 'ssh_hostname' is non-empty. In bash and zsh, we also don't need to check for the 'ghostty' command before we attempt to add the target to the cache. That command will safely fail silently if it's not available.
2025-07-09fish: prefer 'command -q' to check for commandsJon Parise
This is a fish built-in 'command' option that's the more idiomatic way to check for the availability of a command. https://fishshell.com/docs/current/cmds/command.html
2025-07-08refactor: apply maintainer feedback to SSH integration scripts across all shellsJason Rayne
- Update Bash script (baseline): Simplify cache checking logic, clarify "xterm-ghostty terminfo" message, remove unnecessary ssh_opts from terminfo installation, remove extra success message - Align ZSH/Fish/Elvish with updated Bash: Remove extra success messages, adopt simplified cache checking, standardize setup messages - Apply Elvish improvements: Remove unnecessary try/catch blocks, use idiomatic error handling patterns - Apply Fish improvements: Replace string pattern matching with efficient `contains` checks on split features list
2025-07-07refactor: simplify terminfo handling and remove base64 dependencyJason Rayne
- Default ssh_term to xterm-256color to eliminate fallback assignments - Remove base64 and replace infocmp -Q2 with standard -0 -x options for compatibility - Use process substitution instead of intermediate ssh_config variable - Always set TERM explicitly since ssh_term is always defined
2025-07-07refactor: simplify SSH terminfo and environment handlingJason Rayne
- Simplify feature detection to use single wildcard check - Replace ssh_env array with simple ssh_term string variable - Use TERM environment prefix instead of save/restore pattern - Remove unnecessary backgrounded subshell for cache operations
2025-07-07refactor: simplify SSH environment variable handlingJason Rayne
- Remove complex ssh_exported_vars tracking and local environment modification in favor of trusting Ghostty's local environment - Replace regex patterns with glob-based feature detection for better performance - Fix local variable declaration consistency throughout - Streamline logic while maintaining all functionality
2025-07-05Merge branch 'main' into ssh-integrationJason Rayne
2025-07-05fix: optimize SSH integration and improve error handlingJason Rayne
- Replace dual-loop SSH config parsing with efficient single-pass case statement - Remove overly cautious timeout logic from cache checks for simplicity - Add base64 availability check with xterm-256color fallback when missing - Include hostname in terminfo setup messages for better UX - Maintain SendEnv/SetEnv dual approach for maximum OpenSSH compatibility (relying on SetEnv alone seems to drop some vars during my tests, despite them being explicitly included in AcceptEnv on the remote host)
2025-07-04bash: stop using PS0 for the 'cursor' featureJon Parise
Our use of PS0 (which bash runs before command execution) was causing raw command sequences to be printed between multiple commands in a sequence. $ alias garbage='echo start > echo end' $ garbage start �\���dend I wasn't able to definitely track down all of the reasons for why this only happens in the command sequence case, but I suspect it's related to the way that __ghostty_preexec runs from within the bash DEBUG trap (by way of bash-preexec). This problem occurs when PS0 is set to _any_ string (even "") inside of __ghostty_preexec, which also rules out most/any Ghostty-specific code. PS1 and PS2 appear to be safe to (re)set in this context. Fortunately, we can avoid using PS0 entirely by instead printing the cursor reset escape sequence directly from __ghostty_precmd because it also runs just before command execution.
2025-07-03feat(ssh): rewrite SSH cache system in native ZigJason Rayne
- Eliminates standalone bash dependency - Consolidates `+list-ssh-cache` and `+clear-ssh-cache` actions into single `+ssh-cache` action with args - Structured cache format with timestamps and expiration support - Memory-safe entry handling with proper file locking - Comprehensive hostname validation (IPv4/IPv6/domains) - Atomic updates via temp file + rename - Updated shell integrations for improved cross-platform support and reliability - Cache operations are now unit-testable
2025-07-03docs: update to reflect changes after porting terminfo host caching to ZigJason Rayne
- Minor tweak to Config.zig to show the new action. - Rolled back README.md to remove reference to the now non-existent 'shared' subdir and bash-based cache script.
2025-06-25fix: replace non-existent GHOSTTY_VERSION with TERM_PROGRAM_VERSION in shell ↵Jason Rayne
integration GHOSTTY_VERSION was mistakenly referenced but is never set. Use TERM_PROGRAM_VERSION which is actually provided by Exec.zig from build_config.version_string.
2025-06-25docs: call out bash dependencyJason Rayne
2025-06-25style: revert fish_indent quote removalJason Rayne
forgot to disable autoformat for this buffer (again)
2025-06-25refactor: replace ghostty wrapper with proper CLI actions for terminfo cache ↵Jason Rayne
management - Add +list-ssh-cache and +clear-ssh-cache CLI actions - Remove ghostty() wrapper functions from all shell integrations - Improve variable naming in shell scripts for readability Addresses @00-kat's feedback about CLI discoverability and naming consistency. The new CLI actions follow established Ghostty patterns and are discoverable via `ghostty --help`, while maintaining clean separation of concerns between shell logic and cache management.
2025-06-25docs: add shared directory section to shell-integration READMEJason Rayne
2025-06-25refactor: extract SSH cache functionality to shared scriptJason Rayne
Addresses feedback about separation of concerns in shell integration scripts. Extracts host caching logic to `src/shell-integration/shared/ghostty-ssh-cache` and updates all four shell integrations to use the shared script. The `shared/` subdirectory preserves the existing organizational pattern where all shell-specific code lives in subdirectories. This cleanly separates SSH transport logic from cache management while reducing code duplication by ~25%. All existing SSH integration behavior remains identical.
2025-06-25ssh-integration: replace levels with flags, optimize implementationJason Rayne
Rewrote shell functions to support the two new flags for shell-integration-features: - ssh-env: TERM compatibility + best effort environment variable propagation (anything beyond TERM will depend on what the remote host allows) - ssh-terminfo: automatic terminfo installation with control socket orchestration - Flags work independently or combined Implementation optimizations: - ~65% code reduction through unified execution path - Eliminated GHOSTTY_SSH_INTEGRATION environment variable system - Replaced complex function dispatch with direct flag detection - Consolidated 4 cache helper functions into single _ghst_cache() utility - Simplified control socket management (removed multi-step orchestration) - Subsequent connections to cached hosts are now directly executed and more reliable New additions: - If ssh-terminfo is enabled, ghostty will be wrapped to provide users with convenient commands to invoke either of the two utility functions: `ghostty ssh-cache-list` and `ghostty ssh-cache-clear`
2025-06-25fix: update cache file locationJason Rayne
2025-06-25fix: catch up to current stateJason Rayne
2025-06-25ssh-integration: improve host caching, new method for "full" integrationJason Rayne
Need a sanity check on this new approach for "full" to help determine if it's worth additional iteration/refinement. It solves the double auth issue, successfully propagates env vars, and avoids output noise for connections that happen after terminfo is installed. The only issue I don't have time to fix tonight is the fact that it drops the MOTD for cached (re)connections.
2025-06-25fix: manual formatting pass to ensure consistency with existing patternsJason Rayne
2025-06-25fix: add client-side caching to eliminate redundant terminfo installationsJason Rayne
- Cache known hosts with terminfo in $GHOSTTY_RESOURCES_DIR/terminfo_hosts - Skip installation step for cached hosts (single connection instead of two) - Use secure file permissions (600) and atomic writes - Extract SSH target safely from command arguments - Maintains full functionality while improving user experience on repeated connections
2025-06-25fix: address comprehensive shell integration code review issuesJason Rayne
- Fix elvish function name mismatch and use conj for list operations - Simplify terminfo installation command per ghostty docs (tic -x -) - Fix conditional structure to ensure error messages always print - Remove redundant checks and optimize array initialization - Use consistent patterns across bash, fish, elvish, and zsh implementations
2025-06-25fix: add builtin prefix for safety and consistencyJason Rayne
2025-06-25fix: remove resources_dir var, add builtin prefix for consistencyJason Rayne
2025-06-25fix: remove dangling resources_dir varJason Rayne
2025-06-25fix: critical elvish syntax errors for environment variablesJason Rayne
2025-06-25fix: use idiomatic Fish shell syntax in SSH integrationJason Rayne
- Use `set --append` for array operations - Use `type -q` for command existence checks
2025-06-25fix: clean up SSH environment variable propagationJason Rayne
2025-06-25fish: revert all formatting changesJason Rayne
Keeps only functional additions for SSH integration wrapper, preserving original line breaks and indentation to minimize diff noise per maintainer feedback.
2025-06-25bash: revert all formatting changesJason Rayne
Keeps only functional additions for SSH integration wrapper, preserving original line breaks and indentation to minimize diff noise per maintainer feedback.
2025-06-25bash: preserve mixed indentation in SSH integration changesJason Rayne
Preserves existing mixed indentation in ghostty.bash to minimize diff noise per maintainer feedback.
2025-06-25refactor: simplify ssh integration environment variable checksJason Rayne
2025-06-25fix: use kebab-case for ssh-integration enum valuesJason Rayne