31 Commits

Author SHA1 Message Date
Edmund Miller
3829cc5def zsh: Generalize shebang
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
2024-07-25 08:56:06 -05:00
Jon Parise
aa47047a6e bash: ghostty doesn't support OSC 133;P
Remove OSC 133;P marks in the basic prompts, and use OSC 133;A in the
multiline case.
2024-07-22 10:53:50 -04:00
Jon Parise
2bf1f80f77 bash: add primary and secondary marks to PS1 and PS2
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.
2024-07-19 07:44:41 -04:00
Jon Parise
00fe956b3b bash: always send "end of command" prompt sequence
I noticed that both wezterm[0] and the OSC 133 reference script[1] (upon
which wezterm and our bash integration appear to be based) always send
the "end of prompt" sequence in their precmd functions (except during
their first execution, when no previous command has been executed).

This is a subtle logical difference: `$_ghostty_executing=""` (first
run) versus `$_ghostty_executing="0"` (reentrancy check). I'm not sure
how much a difference it makes except in rare edge case scenarios, but I
think it makes sense to be consistent and always report the end of the
current command.

[0] https://github.com/wez/wezterm/blob/main/assets/shell-integration/wezterm.sh#L479
[1] https://gitlab.freedesktop.org/Per_Bothner/specifications/-/blob/master/proposals/prompts-data/shell-integration.bash
2024-07-18 10:31:41 -04:00
Jon Parise
7d7fa46b0c shell-integration: bash must be explicitly enabled
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.
2024-06-03 20:34:29 -04:00
ilk
e5411284dd fix(elvish-integration): fix mistakes
fix some missing imports and (shamefully) faulty logic.
2024-05-31 12:20:12 +03:00
Mitchell Hashimoto
66a9b1b99f rename env var 2024-05-27 16:18:51 -07:00
Mitchell Hashimoto
982e4c9570 prettier 2024-05-27 16:16:43 -07:00
ilk
2863d2c148 refactor(shell-integration): refactor to make cases alphabetical
also fix: build errors
also fix: name mismatch (GHOSTTY_FISH_XDG_DIR -> GHOSTTY_INTEGRATION_DIR)
also refactor elvish file to evade unobvious returns
2024-05-27 16:15:13 -07:00
ilk
1fa830cc73 feat(shell-integration): add automatic integration for Elvish
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.
2024-05-27 16:15:01 -07:00
Mitchell Hashimoto
17e7ff1de3 shell-integration: add README about Elvish 2024-05-27 16:11:08 -07:00
ilk
a1a97913d3 refactor(shell-integration:elvish): refactor to improve readability 2024-05-17 18:11:00 +03:00
ilk
597328432c feat(shell-integration): add integration for Elvish
- 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
2024-05-16 20:45:14 +03:00
Mitchell Hashimoto
cbcb4b27bc Merge pull request #1766 from jparise/bash-readme
shell-integration: update Bash integration details
2024-05-14 18:22:16 -04:00
Jon Parise
d5414d50ea shell-integration: update Bash integration details 2024-05-14 15:06:05 -07:00
Jon Parise
11f3400e49 shell-integration: suppress shellcheck issues 2024-05-14 06:57:02 -07:00
Jon Parise
baf5116140 shell-integration: update bash-preexec.sh
This pulls in a fix for `bind -x` bindings unintentionally calling the
preexec hook: https://github.com/rcaloras/bash-preexec/pull/152
2024-05-10 09:39:26 -07:00
Jon Parise
73b3560e62 shell-integration: automatic bash integration
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).
2024-05-05 13:59:52 -07:00
Marius Svechla
e34b373426 shell-integration: implement no-title option
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.
2024-04-03 22:00:42 +02:00
Atanas Pepechkov
ee1366a0a8 add sudo wrapper as optional shell integration feature 2024-01-13 18:56:21 +02:00
Tim Culverhouse
4fac674016 shell-integration: implement "no-cursor" option
Implement a "no-cursor" option for shell integration. This option acts
like "detect" but doesn't set the cursor shape.
2023-11-07 16:31:07 -06:00
Mitchell Hashimoto
0bdd73797e Fix rendering issues with bash shell integration (#301)
* shell-integration/bash: we need to wrap escape sequences in brackets

* nix: install bashInteractive on Linux
2023-08-17 22:42:26 -07:00
Mitchell Hashimoto
9d61212451 Simplify Bash Integration (#299)
* shell-integration: new bash integration that is much simpler

* shell-integration: bash fixes
2023-08-17 21:50:42 -07:00
Mitchell Hashimoto
a058bcbdb0 shell-integration: add bash script (no auto-inject yet) 2023-08-17 13:26:06 -07:00
Kevin Hovsäter
22b8173164 Fix typos 2023-08-08 14:27:34 +02:00
Mitchell Hashimoto
363e911f77 shell-integration/zsh: enable title changes 2023-08-04 11:14:45 -07:00
Mitchell Hashimoto
80e2cd4e78 zsh integration 2023-07-06 17:46:54 -07:00
Mitchell Hashimoto
4cdad44119 zsh files starting 2023-07-06 16:42:01 -07:00
Mitchell Hashimoto
efd7cb35b8 fish: pwd reporting 2023-07-06 16:15:30 -07:00
Mitchell Hashimoto
ad62e3ac1b fish shell integration 2023-07-06 16:10:30 -07:00
Mitchell Hashimoto
848943770a start shell-integration folder, copy into zig-out 2023-07-06 13:26:28 -07:00