Fails on NixOS
/nix/store/lkqjw3yazk7d3il8a0rp11pvjxdyq281-ghostty-0.1.0/share/ghostty/shell-integration/zsh/ghostty-integration: bad interpreter: /bin/zsh: no such file or directory
These OSC 133 semantic prompt sequences mark the primary and secondary
parts of the prompt strings.
PS1 is marked as the primary (initial) prompt. This is the default, so
we could skip emitting these sequences, but they're added here for now
to be explicit and consistent with what other terminal emulators do in
their shell integrations.
If PS1 is a multiline prompt (i.e. it contains a newline), we mark the
last line as a secondary prompt (k=s). bash doesn't redraw the leading
lines of a multiline prompt on its own, so we can use this information
at runtime to prevent the preceding lines from being erased by ghostty
after a resize.
PS2 is always marked as a secondary prompt.
For now, bash integration must be explicitly enabled (by setting
`shell-integration = bash`). Our automatic shell integration requires
bash version 4 or later, and systems like macOS continue to ship bash
version 3 by default. This approach avoids the cost of performing a
runtime version check.
Fish automatic integration taken as an example.
Just like fish, Elvish checks `XDG_DATA_DIRS` for its modules.
Thus, Fish integration in zig is reused, and integration in
Elvish now removes `GHOSTTY_FISH_XDG_DIR` environment variable
on launch.
- contains `.elv` file that implements the core of Elvish integration.
- does not contain routines needed for automatic integration.
- stored in `./elvish/lib/...` in preparation for automatic integration:
Elvish imports `.../elvish/lib/*.elv`.
checklist:
- no confirmation on close where the cursor is at prompt:
works, only occasionally doesn't, I'm not yet sure when.
- new terminals start in pwd of previously focused terminal: works
- prompts resize correctly: works
- triple-click while holding `ctrl` selects output of a command:
works (when mouse is over the output)
- cursor at the prompt is turned into a bar: works
- ghostty:`jump_to_prompt` scrolls through prompts: works
- `opt`-click moves cursor at the prompt: works
- `sudo` preserves ghostty terminfo:
untested - not sure when this is needed exactly, but did not encounter
any errors after sudo, either
This change adds automatic bash shell detection and integration.
Unlike our other shell integrations, bash doesn't provide a built-in
mechanism for injecting our ghostty.bash script into the new shell
environment.
Instead, we start bash in POSIX mode and use the ENV environment
variable to load our integration script, and the rest of the bash
startup sequence becomes the responsibility of our script to emulate
(along with disabling POSIX mode).
This adds a new option to the shell integration feature set, `no-title`.
If this option is set, the shell integration will not automatically
update the window title.