Commit Graph

990 Commits

Author SHA1 Message Date
Jeffrey C. Ollie
3feef353d8 gtk: clarify in the docs that config-reloads does not affect linux-cgroup* configs 2026-02-17 12:54:29 -06:00
Jeffrey C. Ollie
1342eb5944 gtk: revamp cgroup/transient scope handling
This changes the way Ghostty assigns itself and subprocesses to
cgroups and how resource controls are applied.

* Ghostty itself no longer modifies it's own cgroup or moves itself
to a transient scope. To modify the main Ghostty process' resource
controls ensure that you're launching Ghostty with a systemd unit and
use the standard systemd methods for overriding and applying changes
to systemd units.

* If configured (on by default), the process used to run your command
will be moved to a transient systemd scope after it is forked from
Ghostty but before the user's command is executed. Resource controls
will be applied to the transient scope at this time. Changes to
the `linux-cgroup*` configuration entries will not alter existing
commands. If changes are made to the `linux-cgroup*` configuration
entries commands will need to be relaunched. Resource limits can also
be modified after launch outside of Ghostty using systemd tooling. The
transient scope name can be shown by running `systemctl --user whoami`
in a shell running inside Ghostty.

Fixes #2084.
Related to #6669
2026-02-17 12:54:26 -06:00
Mitchell Hashimoto
f0a1b05f63 rename config 2026-02-17 09:54:34 -08:00
Mitchell Hashimoto
50698c5c72 fmt 2026-02-17 09:18:03 -08:00
Jake Stewart
44d2ea25d0 explain mask 2026-02-17 09:17:54 -08:00
Jake Stewart
7729714935 refactor 256 color gen 2026-02-17 09:17:54 -08:00
Jake Stewart
5f89228a7a refactor lab colors 2026-02-17 09:17:54 -08:00
Jake Stewart
fad72e0ed1 generate 256 palette 2026-02-17 09:17:54 -08:00
Mitchell Hashimoto
7895bf1d02 shell-integration: respect cursor-style-blink (#10643)
The `cursor` shell feature always used a blinking bar (beam), often to
the surprise of users who set `cursor-style-blink = false`.

This change extends our GHOSTTY_SHELL_FEATURES format to include either
`cursor:blink` (default) or `cursor:steady` based on cursor-style-blink
when the `cursor` feature is enabled, and all shell integrations have
been updated to use that additional information to choose the DECSCUSR
cursor value (5=blinking bar, 6=steady bar).

I also considered passing a DECSCUSR value in GHOSTTY_SHELL_FEATURES
(e.g. `cursor:5`). This mostly worked well, but zsh also needs the blink
state on its own for its block cursor. We also don't support any other
shell feature cursor configurability (e.g. the shape), so this was an
over generalization.

This does change the behavior for users who like the blinking bar in the
shell but have `cursor-blink-style = false` for other reasons. We could
provide additional `cursor` shell feature configurability (e.g.
`cursor:blink` in `shell-integration-features`), but I'll propose that
as its own change.

See: #2812
Closes: #8681

---

**AI Disclosure:** I did a lot of rubber ducking with Claude Code while
trying out various ideas. It was particularly useful for this kind of
feature because I could try out one thing and have it evaluate the
impact on all of the shell integration scripts at once.
2026-02-16 14:08:23 -08:00
Mitchell Hashimoto
9bd74fd743 more clickable file path fixes (#10619)
This pull request addresses some of the remaining issues when matching
`~`, `$VAR`, `.directory/`, and embedded commas. It does not address
issues with embedded line breaks.

The PR is split in multiple commits carefully applying a set of changes
to

1. make the big regex more composable / readable
2. update some doc strings
3. add more test cases for the issues mentioned
4. two simple commits, each fixing the issues

Changes:

- **url: refactor regex into documented branches**
  Break up the big monolithic URL and path regex into named sub-pattern
  constants and compose the final expression from three commented
  branches:
  
  - URLs with a scheme
  - absolute or dot-relative paths
  - bare relative paths
  
  This commit only breaks up the regex. It keeps the existing matching
  behavior unchanged.
  

- **url: update top-level comment**
  

- **url: carefully extend test cases**
  Extend existing test cases with `~`, `$VAR`, and bare .-prefixed paths
  and embedded `,` comma handling.
  
  See following issue comments:
  
-
https://github.com/ghostty-org/ghostty/pull/10570#issuecomment-3853842036
-
https://github.com/ghostty-org/ghostty/issues/1972#issuecomment-3859329233
-
https://github.com/ghostty-org/ghostty/issues/1972#issuecomment-3857881196
  

- **url: remove `,` from path_chars**
  Related to #1972
  
  Fixes an issue when paths have embedded comma, e.g.:
  
      shared/src/foo/SomeItem.m:12, shared/src/
  
  with path_chars greedily consuming the rest of the string.
  
  Now file path matching stops at comma. Scheme URLs are unchanged and
  still using the comma.
  

- **url: fix matching `~`, `$VAR`, `.directory/`**
  Related to #1972
  
  This commit adds three new alternatives for
  `rooted_or_relative_path_prefix`:
  
  - `~/`
  - `$VAR` and
  - `.local/`, `.config/` etc. for dot-prefixed directory names
  
Remaining commits fix edge cases one by one:

  - **url: fix mid-string dot partial matches**
    `"foo.local/share"` (was partial match) → now matches fully
    
  - **url: fix $-numeric character matches**
    `"$10/$20"` → no match
    
  - **url: fix partial match of mid string $-variable**
    `"foo/$BAR/baz"` (was partial match) → matches fully now
    
  - **url: fix incomplete $-numeric behavior**
    `"$10/bar.txt"` (was partial match) → but should not match at all
2026-02-15 15:15:58 -08:00
Leah Amelia Chen
61e347a2c2 core/gtk: add language config entry to override GUI localization (#10428)
Fixes #10276

<img width="853" height="637" alt="Screenshot From 2026-01-23 16-45-11"
src="https://github.com/user-attachments/assets/aff9d2f8-eb3e-411e-bd3d-ebd32e5c7973"
/>
2026-02-15 00:24:30 +08:00
Ben Kircher
7d87a58a73 url: fix trailing colon in path matches
Paths like `./.config/ghostty:` and `./Downloads:` were incorrectly
including the trailing colon. Add a `no_trailing_colon` lookbehind to
all path branches and prevent space segments from starting after a colon
so that `": text"` is not consumed as part of the path.
2026-02-14 09:42:07 +01:00
Ben Kircher
bbcc22746a urls: fix over-matching single spaced paths
This commit adds a negative lookahead `(?!\w+://)` to both
`dotted_path_space_segments` and `any_path_space_segments`. This
prevents the space-segment matching from consuming text that starts with
a URL scheme (like http://), which was causing /tmp/test.txt
http://www.google.com to over-match.

Fixes
https://github.com/ghostty-org/ghostty/issues/1972#issuecomment-3882254792
2026-02-11 09:47:28 +01:00
Ben Kircher
50ba394ed3 url: do not match on //
Double-slash comments are not paths so do not match on them.
2026-02-11 09:34:52 +01:00
Ben Kircher
23d22c457a url: fix , handling for spaced paths
Update path_space_segments patterns to consistently handle
comma-delimiters.
2026-02-11 09:34:52 +01:00
Ben Kircher
38831436ea url: fix tilde mid-word partial matches
Don't match `~` mid-word or before `/`.
2026-02-11 09:34:52 +01:00
Ben Kircher
270ee5468f url: fix $VAR mid-word partial matches
Add `(?<!\w)` to prefixes so that $VAR cannot match mid-word.
2026-02-11 09:34:52 +01:00
Ben Kircher
02749cb1dc url: fix comma handling
This string

    foo/bar,baz.txt

should not match but

    src/foo.c,baz.txt

should.

Remove `,` from dotted_path_lookahead and non_dotted_path_lookahead.
2026-02-11 09:34:52 +01:00
Ben Kircher
19a41eb26b url: allow numeric characters at start
Amends and fixes the last commit which was too simpel. This commit uses
a lookbehind to prevent matching $-numeric patterns.
2026-02-11 09:34:52 +01:00
Ben Kircher
99320714bc url: fix incomplete $-numeric behavior
This

    $10/bar.txt

was partially matching but should not match at all.

This commit fixes this by simply `[\w]` to `[A-Za-z_]` as the first
character of a bare relative path, so digit-starting fragments can't
match.

Another option would be a lookbehind but I think the check above is much
simpler.
2026-02-11 09:34:52 +01:00
Ben Kircher
77ee47c18f url: fix partial match of mid string $-variable
A string like this

    foo/$BAR/baz

should match fully, not partially.

This commit fixes this by expanding `\$[A-Za-z_]\w*\/` to
`(?:[\w][\w\-.]*\/)*\$[A-Za-z_]\w*\/` in rooted_or_relative_path_prefix
so that we optionally eat everything before a variable `$VAR/`.
2026-02-11 09:34:52 +01:00
Ben Kircher
af643a1a21 url: fix $-numeric character matches
Strings like

    $10/$20

Should not match.

This commit fixes this by narrowing `\w` after `$` to `[A-Za-z_]` which
is— according to Google Gemini— what environment variables can start
with.
2026-02-11 09:34:52 +01:00
Ben Kircher
0f904d92e0 url: fix mid-string dot partial matches
A string like

    foo.local/share

should match fully, not partially.

This commit fixes this by moving `dotted_path_lookahead` before
`bare_relative_path_prefix` so the dot-check scans the entire match
rather than only the text after it.
2026-02-11 09:34:52 +01:00
Ben Kircher
d8eb89f384 url: fix matching ~, $VAR, .directory/
Related to #1972

This commit adds three new alternatives for
`rooted_or_relative_path_prefix`:

- `~/`
- `$VAR` and
- `.local/`, `.config/` etc. for dot-prefixed directory names
2026-02-11 09:34:52 +01:00
Ben Kircher
72a894b13b url: remove , from path_chars
Related to #1972

Fixes an issue when paths have embedded comma, e.g.:

    shared/src/foo/SomeItem.m:12, shared/src/

with path_chars greedily consuming the rest of the string.

Now file path matching stops at comma. Scheme URLs are unchanged and
still using the comma.
2026-02-11 09:34:52 +01:00
Ben Kircher
c6e0de0bae url: carefully extend test cases
Extend existing test cases with `~`, `$VAR`, and bare .-prefixed paths
and embedded `,` comma handling.

See following issue comments:

- https://github.com/ghostty-org/ghostty/pull/10570#issuecomment-3853842036
- https://github.com/ghostty-org/ghostty/issues/1972#issuecomment-3859329233
- https://github.com/ghostty-org/ghostty/issues/1972#issuecomment-3857881196
2026-02-11 09:34:52 +01:00
Ben Kircher
f38366b5dc url: update top-level comment 2026-02-11 09:34:52 +01:00
Ben Kircher
16a076bd7f url: refactor regex into documented branches
Break up the big monolithic URL and path regex into named sub-pattern
constants and compose the final expression from three commented
branches:

- URLs with a scheme
- absolute or dot-relative paths
- bare relative paths

This commit only breaks up the regex. It keeps the existing matching
behavior unchanged.
2026-02-11 09:34:52 +01:00
Jon Parise
3cfb9d64d1 shell-integration: respect cursor-style-blink
The `cursor` shell feature always used a blinking bar (beam), often to
the surprise of users who set `cursor-style-blink = false`.

This change extends our GHOSTTY_SHELL_FEATURES format to include either
`cursor:blink` (default) or `cursor:steady` based on cursor-style-blink
when the `cursor` feature is enabled, and all shell integrations have
been updated to use that additional information to choose the DECSCUSR
cursor value (5=blinking bar, 6=steady bar).

I also considered passing a DECSCUSR value in GHOSTTY_SHELL_FEATURES
(e.g. `cursor:5`). This mostly worked well, but zsh also needs the blink
state on its own for its block cursor. We also don't support any other
shell feature cursor configurability (e.g. the shape), so this was an
over generalization.

This does change the behavior for users who like the blinking bar in the
shell but have `cursor-blink-style = false` for other reasons. We could
provide additional `cursor` shell feature configurability, but I think
that's best left to a separate change.
2026-02-10 18:46:36 -05:00
Ben Kircher
6c0a17cccf Fix clicking bare relative file paths
Related to #1972

The URL regex for file path detection requires paths to start with
`../`, `./`, or `/`. For bare relative paths like
`"src/config/url.zig"`, the regex could only match starting at the first
`/`, producing `"/config/url.zig"` as a result — always dropping the
first part of the path.

Fix: added a third top-level alternative to the regex. This matches bare
relative paths where:

1. The first component is word characters (possibly with dots/dashes):
   `[\w][\w\-.]*\/`
2. The remaining path must contain a dot (via positive lookahead) — this
   requires a file extension to avoid false positives on text like
   input/output
3. Add a `(?<!\w)\/` instead of `\/` in the existing prefix group — the
   standalone `/` prefix now requires that `/` is not preceded by a word
   character. This prevents `"input/output"` from falsely matching
   `"/output"`

Test cases added:
- src/config/url.zig → matches fully
- app/folder/file.rb:1 → matches with line number
- modified:   src/config/url.zig → matches only the path part
- lib/ghostty/terminal.zig:42:10 → matches with line:col
- some-pkg/src/file.txt more text → stops before trailing text
- input/output and foo/bar → correctly do not match (no file extension)

The issue was nailed down here:
https://github.com/ghostty-org/ghostty/issues/1972#issuecomment-3845717672
2026-02-04 15:17:46 +01:00
Jeffrey C. Ollie
50d9e03424 core/gtk: add language config entry to override GUI localization
Fixes #10276
2026-01-23 17:22:59 -06:00
ClearAspect
8d2eb280db custom shaders: add colorscheme information to shader uniforms
Adds palette and color scheme uniforms to custom shaders, allowing
custom shaders to access terminal color information:

  - iPalette[256]: Full 256-color terminal palette (RGB)
  - iBackgroundColor, iForegroundColor: Terminal colors (RGB)
  - iCursorColor, iCursorText: Cursor colors (RGB)
  - iSelectionBackgroundColor, iSelectionForegroundColor: Selection
colors (RGB)

Colors are normalized to [0.0, 1.0] range and update when the palette
changes via OSC sequences or configuration changes. The palette_dirty
flag tracks when colors need to be refreshed, initialized to true to
ensure correct colors on new surfaces.
2026-01-20 11:15:09 -08:00
Martin Emde
c2deda3231 config: switch certain physical keybinds to unicode
Switches several default keybindings from physical key codes

`.physical = .equal // or .bracket_left or .bracket_right`

to unicode characters

`.unicode = '=' // or '[' or ']'`

to support alternative keyboard layouts like Dvorak and
keyboards with dedicated plus keys (like German layouts).

I found in testing that all of these must be fixed at once otherwise
the bracket physical keys overshadew the correct (for dvorak) plus key.
With this fix, tab and pane navigation (cmd+[], cmd+shift+[]), as well
as cmd+shift+equals and cmd+equals work as expected on dvoark layout on MacOS.
2026-01-20 09:58:34 -08:00
Mitchell Hashimoto
2e0141fcdf config: clarify selection-word-boundary docs 2026-01-20 09:38:41 -08:00
mauroporras
9b7c20f500 refactor: use u21 for Unicode codepoints and Zig 0.15 ArrayList
- Change all codepoint types from u32 to u21 to align with Zig stdlib
- Update ArrayList to use Zig 0.15 unmanaged pattern (.empty)
- Remove unnecessary @intCast when encoding UTF-8
- Fix formatEntry to use stack-allocated buffer
2026-01-20 09:37:31 -08:00
mauroporras
6f662d70bc refactor: clean up selection-word-chars documentation and formatting 2026-01-20 09:37:31 -08:00
mauroporras
27602bb4b4 refactor: optimize selection-word-chars with pre-parsed codepoints
Refactor the selection-word-chars implementation to parse UTF-8 boundary
characters once during config initialization instead of on every selection
operation.

Changes:
- Add SelectionWordChars type that stores pre-parsed []const u32 codepoints
- Parse UTF-8 to codepoints in parseCLI() during config load
- Remove UTF-8 parsing logic from selectWord() hot path (27 lines removed)
- Remove arbitrary 64-character buffer limit
- Update selectWord() and selectWordBetween() to accept []const u32
- Update DerivedConfig to store codepoints directly
- Update all tests to use codepoint arrays

Benefits:
- No runtime UTF-8 parsing overhead on every selection
- No arbitrary character limit (uses allocator instead)
- Cleaner separation of concerns (config handles parsing, selection uses data)
- Better performance in selection hot path
2026-01-20 09:37:31 -08:00
mauroporras
811e3594eb feat: add configurable word boundary characters for text selection
Add new `selection-word-chars` config option to customize which characters
mark word boundaries during text selection operations (double-click, word
selection, etc.). Similar to zsh's WORDCHARS environment variable, but
specifies boundary characters rather than word characters.

Default boundaries: ` \t'"│`|:;,()[]{}<>$`

Users can now customize word selection behavior, such as treating
semicolons as part of words or excluding periods from boundaries:

    selection-word-chars = " \t'\"│`|:,()[]{}<>$"

Changes:
- Add selection-word-chars config field with comprehensive documentation
- Modify selectWord() and selectWordBetween() to accept boundary_chars parameter
- Parse UTF-8 boundary string to u32 codepoints at runtime
- Update all call sites in Surface.zig and embedded.zig
- Update all test cases to pass boundary characters
2026-01-20 09:37:31 -08:00
Mitchell Hashimoto
6730afe312 macOS: Add GhosttyUITests (Drafting to save some ci checks) (#9185)
### Background

~~I was trying to add a few UI test cases for
`macOS-titlebar-style`[Already in this PR]~~. In order to do this, I
need a way from `GhosttyKit` to load a temporary configuration without
messing around with users'.

### Changes

- Add `ghostty_config_load_file` using the existing
[`loadFile`](dafb9e89a3/src/config/Config.zig (L3399))
- Use `xcbeautify` to format test&build errors
**Couldn't find a way to do this in `GhosttyXcodebuild`, if you have a
better approach please let me know!**
- Add GhosttyUITests target and test cases for
`GhosttyTitlebarTabsUITests`(#2349) and `GhosttyThemeTests`(#9360)

### NOTE

Running UI tests on the runner could be **very** slow and I couldn't
find a way to guarantee success, so I made these only runnable by
manually testing in Xcode.

Better to squash this🤪

> > Some of the test cases could fail when testing all the cases
together; a rerun would succeed.
2026-01-20 09:30:39 -08:00
Lars
9c5d4a5511 ghosttyKit: add ghostty_config_load_file 2026-01-20 09:15:14 -08:00
Jon Parise
7e3c9f4d5a shell-integration: initial nushell shell integration
Nushell <https://www.nushell.sh/> is a modern interactive shell that
provides many shell features out-of-the-box, like `title` support. Our
shell integration therefore focuses on Ghostty-specific features like
`sudo`.

We use Nushell's module system to provide a `ghostty` module containing
our shell integration features. This module is automatically loaded from
$XDG_DATA_DIRS/nushell/vendor/autoload/ when `nushell` shell integration
is enabled.

Exported module functions need to be explicitly "used" before they're
available to the interactive shell environment. We do that automatically
by adding `--execute "use ghostty *"` to the `nu` command line.

This imports all available functions, and individual shell features are
runtime-guarded by the script code (using $GHOSTTY_SHELL_FEATURES). We
can consider further refining this later.

When automatic shell integration is disabled, users can still manually
source and enable the shell integration module:

    source $GHOSTTY_RESOURCES_DIR/shell-integration/nushell/vendor/autoload/ghostty.nu
    use ghostty *

This initial work implements our TERMINFO-aware `sudo` wrapper (via the
`sudo` shell feature). Support for additional features, like `ssh-env`
and `ssh-terminfo`, will follow.
2026-01-11 11:27:19 -05:00
Mitchell Hashimoto
ec2912dbaf docs: bell border feature is available on macOS (#10242)
As of commit fe55d90 and PR #8768 this feature is also available on
macOS.
2026-01-09 11:40:12 -08:00
Martin Müller
d94ba5cf10 docs: add bell border feature version availability
Commit 22fc90f (PR #8222) on GTK and commit fe55d90 (PR #8768) on macOS.
2026-01-09 18:46:00 +01:00
Mitchell Hashimoto
0e9ce7e450 input: change our binding set to use array hash map
This is recommended for ongoing performance: 
https://github.com/ziglang/zig/issues/17851

Likely not an issue for this particular use case which is why it never
bit us; we don't actively modify this map much once it is created. But,
its still good hygiene and ArrayHashMap made some of the API usage
nicer.
2026-01-09 09:06:03 -08:00
Mitchell Hashimoto
c179de62a7 extract deepEqual 2026-01-09 08:59:05 -08:00
Martin Müller
115351db87 docs: bell border feature is available on macOS
As of commit fe55d90 and PR #8768 this feature is also available on
macOS.
2026-01-09 16:19:50 +01:00
Mitchell Hashimoto
a6d36b5e6d config: add more details to the key-remap feature 2026-01-08 10:45:45 -08:00
Mitchell Hashimoto
5b24aebcab update to use new RemapSet 2026-01-08 10:22:56 -08:00
Mitchell Hashimoto
f804a4344e input: RemapSet 2026-01-08 10:22:56 -08:00
Mitchell Hashimoto
8415d8215b comments 2026-01-08 10:22:56 -08:00