11090 Commits

Author SHA1 Message Date
Mitchell Hashimoto
c12b280782 dbus and systemd activation - take 2 (#7679)
This replaces #7433. The improvements are:

1) Install the systemd user service in the proper directory depending on
if it's a 'user' install or a 'system' install. This is controlled
either by using the `--system` build flag (as most packages will) or by
the `-Dsystem-package` flag.

2) Add the absolute path to the `ghostty` binary in the application
file, the DBus service, and the systemd user service. This is done so
that they do not depend on `ghostty` being in the `PATH` of whatever is
launching Ghostty. That `PATH` is not necessarily the same as the `PATH`
in a user shell (especially for DBus activation and systemd user
services).

3) Adjust the DBus bus name that is expected by the system depending on
the optimization level that Ghostty is compiled with.
2025-06-26 13:31:29 -07:00
Mitchell Hashimoto
d92d1cac2a remove unused TODO.md 2025-06-26 13:16:55 -07:00
Mitchell Hashimoto
3d01bb43cc terminal/Screen: account for rectangle selection in clone (#7692)
Fixes an issue where rectangle selections would appear visually wrong if
their start or end were out of the viewport area, because when cloning
them the restored pins were defaulting to the start and end of the row
instead of the appropriate column.

This issue is shown in discussion #7687.
2025-06-26 13:15:48 -07:00
Mitchell Hashimoto
b4e81949ee wrong service name for dbus systemd service 2025-06-26 13:12:05 -07:00
Mitchell Hashimoto
77654eb01c use tail to clear the first line of the template 2025-06-26 13:07:41 -07:00
Mitchell Hashimoto
739b691a6d use cmake formatting to template, avoids the custom binary 2025-06-26 10:28:46 -07:00
Jeffrey C. Ollie
73d5eb928c fix up formatting of desktop_template.zig 2025-06-26 10:28:46 -07:00
Jeffrey C. Ollie
8a95212197 fix up the name in the metainfo when templating 2025-06-26 10:28:46 -07:00
Jeffrey C. Ollie
fa4f420768 replace sed with a simple Zig program for templating desktop files 2025-06-26 10:28:46 -07:00
Jeffrey C. Ollie
eb5a488b57 clean up duplicated code in installation of desktop services 2025-06-26 10:28:46 -07:00
Jeffrey C. Ollie
9c95ce28ae drop system-package option 2025-06-26 10:28:46 -07:00
Jeffrey C. Ollie
cf561fcc55 rename templated files with .in suffix 2025-06-26 10:28:46 -07:00
Jeffrey C. Ollie
b68f9f2321 make sure that the desktop file uses the absolute path everywhere 2025-06-26 10:28:46 -07:00
Jeffrey C. Ollie
ddada2fb3f flatpak: remove references to systemd unit
Replaces #7676

When building as a flatpak, don't install the systemd user services
since flatpaks can't use them. Remove references to the systemd service
from the DBus service.

Also, customize the app metadata depending on the debug mode.

Co-authored-by: Leorize <leorize+oss@disroot.org>
2025-06-26 10:28:46 -07:00
Jeffrey C. Ollie
81403f59ce dbus and systemd activation - take 2
This replaces #7433. The improvements are:

1) Install the systemd user service in the proper directory depending
on if it's a 'user' install or a 'system' install. This is controlled
either by using the `--system` build flag (as most packages will) or by
the `-Dsystem-package` flag.

2) Add the absolute path to the `ghostty` binary in the application
file, the DBus service, and the systemd user service. This is done so
that they do not depend on `ghostty` being in the `PATH` of whatever
is launching Ghostty. That `PATH` is not necessarily the same as the
`PATH` in a user shell (especially for DBus activation and systemd user
services).

3) Adjust the DBus bus name that is expected by the system depending on
the optimization level that Ghostty is compiled with.
2025-06-26 10:28:46 -07:00
Qwerasd
f7ee6b3bda terminal/Screen: clean up selection remap in clone
Cleans up the logic, checks for out of bounds using rows instead of
sel.contains because that excludes cases where a rectangle selection
doesn't include the leftmost column.

Also adds test for clipping behavior of rectangular selections.
2025-06-26 11:26:03 -06:00
Qwerasd
360124ded0 terminal/Screen: account for rectangle selection in clone
Fixes an issue where rectangle selections would appear visually wrong if
their start or end were out of the viewport area, because when cloning
them the restored pins were defaulting to the start and end of the row
instead of the appropriate column.
2025-06-25 23:16:43 -06:00
Jason Rayne
076f742dd4 fix: replace non-existent GHOSTTY_VERSION with TERM_PROGRAM_VERSION in shell 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-25 17:50:15 -07:00
Jason Rayne
b5372468e4 docs: clarify infocmp/tic requirements for ssh-terminfo feature
infocmp is required locally to extract terminfo, tic is required on
remote hosts to install it
2025-06-25 17:47:26 -07:00
Jason Rayne
eed2006b4d fix: correct resources directory fallback path and eliminate code duplication in ssh_cache
- Fix fallback path from full path to "src" since full path is built
later
- Extract duplicate code from listCachedHosts and clearCache into
runCacheCommand helper
- Addresses feedback from @00-kat
2025-06-25 17:47:01 -07:00
Jason Rayne
1873add697 docs: call out bash dependency 2025-06-25 17:00:17 -07:00
Jason Rayne
e5e2a56c98 fix: use imported modules consistently in action dispatch 2025-06-25 16:47:17 -07:00
Jason Rayne
59229d7681 style: revert fish_indent quote removal
forgot to disable autoformat for this buffer (again)
2025-06-25 16:36:08 -07:00
Jason Rayne
931efcd1e3 fix: restore background-image config accidentally removed during rebase 2025-06-25 16:15:41 -07:00
Jason Rayne
21d95c42c6 docs: improve clear-ssh-cache description (missed in previous commit)
Clarifies this clears hosts cached by SSH shell integration, completing
mitchellh's feedback on both action descriptions.
2025-06-25 15:58:13 -07:00
Jason Rayne
0ccb7cf353 docs: improve SSH cache CLI action descriptions
- Clarify that +list-ssh-cache shows shell integration cached hosts
- Add note about +clear-ssh-cache command and when to use it

Addresses mitchellh's feedback on action descriptions.
2025-06-25 15:46:18 -07:00
Jason Rayne
f617c9b3b7 docs: update ssh-terminfo description to reference new CLI actions
Updates Config.zig documentation to reflect that SSH cache management is
now handled by proper CLI actions (+list-ssh-cache and +clear-ssh-cache)
rather than shell wrapper commands.

Fixes documentation missed in e8c8a51.
2025-06-25 15:46:18 -07:00
Jason Rayne
0565ed3954 refactor: replace ghostty wrapper with proper CLI actions for terminfo cache 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-25 15:46:18 -07:00
Jason Rayne
6789b7fb6e docs: add shared directory section to shell-integration README 2025-06-25 15:46:18 -07:00
Jason Rayne
8a2fa6485e refactor: extract SSH cache functionality to shared script
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-25 15:46:18 -07:00
Jason Rayne
bbb02a8392 test: update shell integration tests for SSH flags
Add ssh-env and ssh-terminfo fields to existing setupFeatures tests.
2025-06-25 15:46:18 -07:00
Jason Rayne
c8d5e60390 docs: expand flag descriptions, usage overview 2025-06-25 15:46:18 -07:00
Jason Rayne
81641e56b1 ssh-integration: replace levels with flags, optimize implementation
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-25 15:46:18 -07:00
Jason Rayne
e73313ed40 change: migrate SSH integration from standalone option to shell-integration-features flags
- Add ssh_env and ssh_terminfo flags to ShellIntegrationFeatures
- Remove SSHIntegration enum and ssh-integration config option
- Update setupFeatures to handle new flags via reflection
- Remove setupSSHIntegration function and all references

Integrates SSH functionality into existing shell-integration-features
system for better consistency and user control.
2025-06-25 15:46:18 -07:00
Jason Rayne
ddd3da487e fix: update cache file location 2025-06-25 15:46:18 -07:00
Jason Rayne
30683979bc fix: catch up to current state 2025-06-25 15:46:18 -07:00
Jason Rayne
f206e76841 ssh-integration: improve host caching, new method for "full" integration
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-25 15:46:18 -07:00
Jason Rayne
69f9976394 fix: manual formatting pass to ensure consistency with existing patterns 2025-06-25 15:46:18 -07:00
Jason Rayne
4cebee5c8e fix: add client-side caching to eliminate redundant terminfo installations
- 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-25 15:46:18 -07:00
Jason Rayne
b6bb9abfbc fix: address comprehensive shell integration code review issues
- 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-25 15:46:18 -07:00
Jason Rayne
995fb09813 fix: add builtin prefix for safety and consistency 2025-06-25 15:46:18 -07:00
Jason Rayne
2ddcf2fffe fix: remove resources_dir var, add builtin prefix for consistency 2025-06-25 15:46:18 -07:00
Jason Rayne
3319b2b6ed docs: added full stop for consistency 2025-06-25 15:46:18 -07:00
Jason Rayne
fb8f6c77dd fix: remove dangling resources_dir var 2025-06-25 15:46:18 -07:00
Jason Rayne
80475e1d17 fix: critical elvish syntax errors for environment variables 2025-06-25 15:46:18 -07:00
Jason Rayne
af28763a34 fix: trailing newline in Config.zig 2025-06-25 15:46:18 -07:00
Jason Rayne
8fafd5ace1 docs: expand SSH integration configuration documentation
Add detailed explanations of shell function behavior, TERM compatibility
trade-offs, environment variable propagation, and authentication
requirements per maintainer feedback.
2025-06-25 15:46:18 -07:00
Jason Rayne
4206ab1210 fix: use idiomatic Fish shell syntax in SSH integration
- Use `set --append` for array operations
- Use `type -q` for command existence checks
2025-06-25 15:46:18 -07:00
Jason Rayne
050cb3bfec fix: remove unnecessary jsonStringify method 2025-06-25 15:46:18 -07:00
Jason Rayne
2e9a0e92db fix: clean up SSH environment variable propagation 2025-06-25 15:46:18 -07:00