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
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.
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.
The previous logic didn't detect the `e` option when it was combined
with other flags (e.g. `-ie`). This change also attempts to improve the
general readability of this code to be a bit more explicit.
bash-preexec implements support for its "precmd" and "preexec" hooks
using a combination of PROMPT_COMMAND and a DEBUG trap. The latter is
unfortunately quick slow (in a relative sense), and the overall system
is a bit more generalized than what we need for our shell integration
(e.g. supporting multiple function hooks, subshells, etc.).
Bash 4.4 introduced the PS0 variable, which is expanded and displayed by
interactive shells after reading a complete command but before executing
it. This is all we need to implement our own shell integration hooks.
In Bash 5.1, PROMPT_COMMAND can be an array variable, each element of
which can contain a command to be executed like a string PROMPT_COMMAND
variable. When adding our hook to PROMPT_COMMAND, we preserve its type
(string or array) to be minimally intrusive. This also matches direnv's
approach.
Bash 5.3 introduced support for function substitution, which is an even
more efficient way to run code from PS0, so we use that when available.
Otherwise, we use the more traditional command substitution approach.
Earlier versions of bash (such as 3.2, which still ships with macOS)
continue to use the bash-preexec path. This gives us two code paths to
maintain, but I think that's preferable to fully maintaining our own
DEBUG trap-based system for older bash versions given that bash-preexec
has proven to work reliably in those environments. We also wouldn't
unlock any other user benefits aside from removing the bash-preexec
script dependency.
See: #3724, #7734
uses the `final` fixed point package set as the source of dependencies
for the ghostty package created by the overlay - allows simpler
overriding of dependencies when using the overlay
no AI used
updates nixpkgs and home-manager
X11 packages are now not in a shared namespace
the ZIG_GLOBAL_CACHE_DIR creation was moved to the configurePhase in the
zig hook
moves nix shell from #devShell.\<system\> to
#devshells.\<system\>.default
tested with `nix run` and `nix flake check` on x86-64_linux
no AI used
According to the [Contributors' Guides for
I18n](https://github.com/ghostty-org/ghostty/blob/main/po/README_CONTRIBUTORS.md):
> This file must stay in sync with the list of translatable strings
present in source code or Blueprints at all times. A CI action would be
run for every PR, which checks if the translation template requires any
updates.
Currently, the CI passes even if the POT file is outdated and has not
been updated for a long time. Add `set -euxo pipefail` to
`check-translations.sh` to ensure the CI fails when contributors do not
update the POT file with their changes.
Before:
```
❯ bash .github/scripts/check-translations.sh; echo "status code: $?"
po/com.mitchellh.ghostty.pot:87: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.YxAlAg28KW
po/com.mitchellh.ghostty.pot:91: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.YxAlAg28KW
po/com.mitchellh.ghostty.pot:95: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.YxAlAg28KW
po/com.mitchellh.ghostty.pot:99: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.YxAlAg28KW
po/com.mitchellh.ghostty.pot:103: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.YxAlAg28KW
po/com.mitchellh.ghostty.pot:110: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.YxAlAg28KW
po/com.mitchellh.ghostty.pot:114: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.YxAlAg28KW
po/com.mitchellh.ghostty.pot:126: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.YxAlAg28KW
po/com.mitchellh.ghostty.pot:297: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.YxAlAg28KW
po/com.mitchellh.ghostty.pot:301: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.YxAlAg28KW
po/com.mitchellh.ghostty.pot:305: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.YxAlAg28KW
msgcmp: found 11 fatal errors
status code: 0
```
After:
```
❯ bash .github/scripts/check-translations.sh; echo "status code: $?"
++ mktemp
+ old_pot=/var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.OfLyQ8IKsR
+ cp po/com.mitchellh.ghostty.pot /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.OfLyQ8IKsR
+ zig build update-translations
+ msgcmp /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.OfLyQ8IKsR po/com.mitchellh.ghostty.pot --use-untranslated
po/com.mitchellh.ghostty.pot:87: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.OfLyQ8IKsR
po/com.mitchellh.ghostty.pot:91: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.OfLyQ8IKsR
po/com.mitchellh.ghostty.pot:95: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.OfLyQ8IKsR
po/com.mitchellh.ghostty.pot:99: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.OfLyQ8IKsR
po/com.mitchellh.ghostty.pot:103: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.OfLyQ8IKsR
po/com.mitchellh.ghostty.pot:110: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.OfLyQ8IKsR
po/com.mitchellh.ghostty.pot:114: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.OfLyQ8IKsR
po/com.mitchellh.ghostty.pot:126: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.OfLyQ8IKsR
po/com.mitchellh.ghostty.pot:297: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.OfLyQ8IKsR
po/com.mitchellh.ghostty.pot:301: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.OfLyQ8IKsR
po/com.mitchellh.ghostty.pot:305: this message is used but not defined in /var/folders/sq/_thdhjtd653cbg8c_8_4r6mc0000gn/T/tmp.OfLyQ8IKsR
msgcmp: found 11 fatal errors
status code: 1
```
PROMPT_COMMAND array support for introduced in bash 5.1, and it's the
preferred format moving forward. Using the string form is also fine, but
it's easy to be a modern bash citizen here, so let's do so.
Add `set -euxo pipefail` to `check-translations.sh` to ensure the CI
fails when contributors do not update the POT file with their changes.
Currently, the CI passes even if the POT file is outdated and the POT
has not been updated for a long time.
bash-preexec implements support for its "precmd" and "preexec" hooks
using a combination of PROMPT_COMMAND and a DEBUG trap. The latter is
unfortunately quick slow (in a relative sense), and the overall system
is a bit more generalized than what we need for our shell integration
(e.g. supporting multiple function hooks, subshells, etc.).
Bash 4.4 introduced the PS0 variable, which is expanded and displayed by
interactive shells after reading a complete command but before executing
it. This is all we need to implement our own shell integration hooks.
In Bash 5.1, PROMPT_COMMAND can be an array variable, each element of
which can contain a command to be executed like a string PROMPT_COMMAND
variable. When adding our hook to PROMPT_COMMAND, we preserve its type
(string or array) to be minimally intrusive. This also matches direnv's
approach.
Bash 5.3 introduced support for function substitution, which is an even
more efficient way to run code from PS0, so we use that when available.
Otherwise, we use the more traditional command substitution approach.
Earlier versions of bash (such as 3.2, which still ships with macOS)
continue to use the bash-preexec path. This gives us two code paths to
maintain, but I think that's preferable to fully maintaining our own
DEBUG trap-based system for older bash versions given that bash-preexec
has proven to work reliably in those environments. We also wouldn't
unlock any other user benefits aside from removing the bash-preexec
script dependency.
See: #3724, #7734
The previous logic didn't detect the `e` option when it was combined
with other flags (e.g. `-ie`). This change also attempts to improve the
general readability of this code to be a bit more explicit.
This adds the ability to use two fingers on a touchpad to scroll left or
right on a Ghostty window to change tab pages. Uses the same basic
machinery as scrolling up and down the scrollback buffer. Scrolling
pages does not wrap around at the start or end of the tabs.
When we're building an input string that's explicitly meant to be used
as a shell command, quote it using the same logic as Python's
`shlex.quote` function.
This specifically addresses issues we've seen when open(1)'ing Ghostty
with filename arguments that contain spaces.
See #2633, #3030
#### [Core Audio Tap API](https://github.com/insidegui/AudioCap)
There's a new NS permission needed for macos (>14.x) to capture system
audio with the `Core Audio Tap API`. Previously desktop-audio capture
was handled by a different permissions API with GUI & preferences. Both
APIs continue to exist but this newer one has a NS permission we should
include. The "geniuses" have spoken and this API doesn't have public
methods for querying the permissions state. As a strong side-effect of
this "feature", failures due to lack of NS permissions are likely to be
handled poorly by software makers.
---
I've spent [the last 5
days](https://github.com/electron/electron/issues/49607) reviewing
C++/Objective-C Chromium source to hone in on why my DesktopAudioCapture
broke on an electron version update. It is in-fact chromium [started
using](source.chromium.org/chromium/chromium/src/+/ad17e8f8b93d5f34891b06085d373a668918255e)
this new `Core Audio Tap API` and has no fallback to the old API if the
new one fails.
Should be your easiest code-review of the week. Shoutout to the
maintainers/creator, big fan of this Zig based terminal with good shader
support.
When we're building an input string that's explicitly meant to be used
as a shell command, quote (escape) it using the same logic as Python's
shlex.quote function.
This specifically addresses issues we've seen when open(1)'ing Ghostty
with filename arguments that contain spaces.
[Reference](https://github.com/insidegui/AudioCap). This is Apple's latest system for allowing apps to access loopback audio streams eg: Desktop-Audio, Window-Audio, etc...
This adds the ability to use two fingers on a touchpad to scroll left
or right on a Ghostty window to change tab pages. Uses the same basic
machinery as scrolling up and down the scrollback buffer. Scrolling
pages does not wrap around at the start or end of the tabs.
Based on some prior private discussion -- this is needed for the GitHub
bot to correctly dispatch, track, and collect workflow runs based on the
triggering PR.
I'm not sure if covering only `build-macos` is enough and if outputs
from other jobs (like `build-macos-debug-slow`) are also useful here. I
went with just `build-macos` since it's the only one to also link a DMG
(and it sounds the most basic of course).
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
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