Merge pull request #1823 from jparise/explicit-bash

shell-integration: bash must be explicitly enabled
This commit is contained in:
Mitchell Hashimoto
2024-06-03 18:43:53 -07:00
committed by GitHub
3 changed files with 14 additions and 1 deletions

View File

@ -208,6 +208,9 @@ function fine within Ghostty with the above mentioned shell integration features
inoperative. **If you want to disable automatic shell integration,** set inoperative. **If you want to disable automatic shell integration,** set
`shell-integration = none` in your configuration file. `shell-integration = none` in your configuration file.
Automatic `bash` shell integration requires Bash version 4 or later and must be
explicitly enabled by setting `shell-integration = bash`.
**For the automatic shell integration to work,** Ghostty must either be run **For the automatic shell integration to work,** Ghostty must either be run
from the macOS app bundle or be installed in a location where the contents of from the macOS app bundle or be installed in a location where the contents of
`zig-out/share` are available somewhere above the directory where Ghostty `zig-out/share` are available somewhere above the directory where Ghostty

View File

@ -18,7 +18,11 @@ our integration script (`bash/ghostty.bash`). This prevents Bash from loading
its normal startup files, which becomes our script's responsibility (along with its normal startup files, which becomes our script's responsibility (along with
disabling POSIX mode). disabling POSIX mode).
Because automatic Bash shell integration requires Bash version 4 or later, it
must be explicitly enabled (`shell-integration = bash`).
Bash shell integration can also be sourced manually from `bash/ghostty.bash`. Bash shell integration can also be sourced manually from `bash/ghostty.bash`.
This also works for older versions of Bash.
### Elvish ### Elvish

View File

@ -57,7 +57,11 @@ pub fn setup(
}; };
const result: ShellIntegration = shell: { const result: ShellIntegration = shell: {
if (std.mem.eql(u8, "bash", exe)) { // For now, bash integration must be explicitly enabled via force_shell.
// 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.
if (std.mem.eql(u8, "bash", exe) and force_shell == .bash) {
const new_command = try setupBash( const new_command = try setupBash(
alloc_arena, alloc_arena,
command, command,
@ -129,6 +133,8 @@ test "force shell" {
/// our script's responsibility (along with disabling POSIX /// our script's responsibility (along with disabling POSIX
/// mode). /// mode).
/// ///
/// This approach requires bash version 4 or later.
///
/// This returns a new (allocated) shell command string that /// This returns a new (allocated) shell command string that
/// enables the integration or null if integration failed. /// enables the integration or null if integration failed.
fn setupBash( fn setupBash(