18 Commits

Author SHA1 Message Date
Jon Parise
63747d1e22 bash: improve clearing of multiline prompts
Bash doesn't redraw the leading lines in a multiline prompt so we mark
the last line as a secondary prompt (k=s) to prevent the preceding lines
from being erased by Ghostty after a resize.

Our previously attempt at this (#1973) was flawed. Instead, we now just
re-issue the OSC "133;A" command with a 'k=s' (secondary) kind at the
end of our prompt string.

This isn't a great solution because it stomps on the prompt's "133;B"
command (end of prompt and start of user input), but it's sufficient for
now and only applies in the multiline prompt case.

Going forward, we should revisit our semantic prompt implementation. Our
row-based approach is too limiting; lines can have multiple markers, and
markers should be recorded with their full coordinates so they can form
ranges.

See: https://per.bothner.com/blog/2019/shell-integration-proposal/
2024-12-17 16:28:41 -05:00
Anund
38b42fc970 shell-integration: add bashrc location lookup in Nixos
fixes #2979
2024-12-17 21:49:15 +11:00
Anthony
7faa73e5fd Remove shebangs from non-executable configuration source scripts 2024-11-15 02:15:09 +11:00
Anthony
387ce53a97 Revert "Update shebangs in installed shellscripts to meet rpmlint and match provided paths at [pkgs.org](https://fedora.pkgs.org/41/fedora-x86_64/elvish-0.21.0-4.fc41.x86_64.rpm.html)"
This reverts commit c936276781107904e9af810e52f3661e91adc629.
2024-11-15 02:13:54 +11:00
Anthony
c936276781 Update shebangs in installed shellscripts to meet rpmlint and match provided paths at [pkgs.org](https://fedora.pkgs.org/41/fedora-x86_64/elvish-0.21.0-4.fc41.x86_64.rpm.html) 2024-11-15 01:29:50 +11:00
Jon Parise
d7331f06e3 bash: stop modifying HISTCONTROL in bash-preexec.sh
This hack is only needed to improve the accuracy of the command argument
passed to the preexec functions, and we don't use that argument in our
bash shell integration script (and nor does the __bp_original_debug_trap
function above, which is the only other active preexec function).

See also:
- https://github.com/rcaloras/bash-preexec/issues/147
- https://github.com/rcaloras/bash-preexec/issues/115

Fixes #2269
2024-10-23 08:09:01 -04: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
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