diff options
| author | Matthew Hrehirchuk <matthew_hre@outlook.com> | 2025-09-30 11:23:02 -0600 |
|---|---|---|
| committer | Matthew Hrehirchuk <matthew_hre@outlook.com> | 2025-09-30 11:26:20 -0600 |
| commit | 4cc663fc6003aa6626d4a9c73f1763b862dc569f (patch) | |
| tree | 4c55603c6b0e3b0be297ea35344e3cf154b88147 /src/shell-integration | |
| parent | ceac472af000ce370520b31a9fba927f55e7aac7 (diff) | |
feat: add GHOSTTY_BIN_DIR to path via shell integration
Diffstat (limited to 'src/shell-integration')
4 files changed, 37 insertions, 0 deletions
diff --git a/src/shell-integration/bash/ghostty.bash b/src/shell-integration/bash/ghostty.bash index 2cf9d388f..cdaddea5c 100644 --- a/src/shell-integration/bash/ghostty.bash +++ b/src/shell-integration/bash/ghostty.bash @@ -73,6 +73,14 @@ if [ -n "$GHOSTTY_BASH_INJECT" ]; then builtin unset GHOSTTY_BASH_RCFILE fi +# Add Ghostty binary to PATH if the path feature is enabled +if [[ "$GHOSTTY_SHELL_FEATURES" == *"path"* && -n "$GHOSTTY_BIN_DIR" ]]; then + # Check if the directory is already in PATH + if [[ ":$PATH:" != *":$GHOSTTY_BIN_DIR:"* ]]; then + export PATH="$PATH:$GHOSTTY_BIN_DIR" + fi +fi + # Sudo if [[ "$GHOSTTY_SHELL_FEATURES" == *"sudo"* && -n "$TERMINFO" ]]; then # Wrap `sudo` command to ensure Ghostty terminfo is preserved. diff --git a/src/shell-integration/elvish/lib/ghostty-integration.elv b/src/shell-integration/elvish/lib/ghostty-integration.elv index 6d0d19f4f..e570e3aec 100644 --- a/src/shell-integration/elvish/lib/ghostty-integration.elv +++ b/src/shell-integration/elvish/lib/ghostty-integration.elv @@ -196,6 +196,19 @@ set edit:before-readline = (conj $edit:before-readline $beam~) set edit:after-readline = (conj $edit:after-readline {|_| block }) } + if (and (has-value $features path) (has-env GHOSTTY_BIN_DIR)) { + # Check if the directory is already in PATH + var path-contains-ghostty = $false + for p $paths { + if (eq $p $E:GHOSTTY_BIN_DIR) { + set path-contains-ghostty = $true + break + } + } + if (not $path-contains-ghostty) { + set paths = [$@paths $E:GHOSTTY_BIN_DIR] + } + } if (and (has-value $features sudo) (not-eq "" $E:TERMINFO) (has-external sudo)) { edit:add-var sudo~ $sudo-with-terminfo~ } diff --git a/src/shell-integration/fish/vendor_conf.d/ghostty-shell-integration.fish b/src/shell-integration/fish/vendor_conf.d/ghostty-shell-integration.fish index daa4f1d4f..fcba767a2 100644 --- a/src/shell-integration/fish/vendor_conf.d/ghostty-shell-integration.fish +++ b/src/shell-integration/fish/vendor_conf.d/ghostty-shell-integration.fish @@ -61,6 +61,14 @@ function __ghostty_setup --on-event fish_prompt -d "Setup ghostty integration" end end + # Add Ghostty binary to PATH if the path feature is enabled + if contains path $features; and test -n "$GHOSTTY_BIN_DIR" + # Check if the directory is already in PATH + if not contains -- "$GHOSTTY_BIN_DIR" $PATH + set --global --export PATH $PATH "$GHOSTTY_BIN_DIR" + end + end + # When using sudo shell integration feature, ensure $TERMINFO is set # and `sudo` is not already a function or alias if contains sudo $features; and test -n "$TERMINFO"; and test "file" = (type -t sudo 2> /dev/null; or echo "x") diff --git a/src/shell-integration/zsh/ghostty-integration b/src/shell-integration/zsh/ghostty-integration index 8607664a2..e76aace4a 100644 --- a/src/shell-integration/zsh/ghostty-integration +++ b/src/shell-integration/zsh/ghostty-integration @@ -220,6 +220,14 @@ _ghostty_deferred_init() { builtin print -rnu $_ghostty_fd \$'\\e[0 q'" fi + # Add Ghostty binary to PATH if the path feature is enabled + if [[ "$GHOSTTY_SHELL_FEATURES" == *"path"* ]] && [[ -n "$GHOSTTY_BIN_DIR" ]]; then + # Check if the directory is already in PATH + if [[ ":$PATH:" != *":$GHOSTTY_BIN_DIR:"* ]]; then + builtin export PATH="$PATH:$GHOSTTY_BIN_DIR" + fi + fi + # Sudo if [[ "$GHOSTTY_SHELL_FEATURES" == *"sudo"* ]] && [[ -n "$TERMINFO" ]]; then # Wrap `sudo` command to ensure Ghostty terminfo is preserved |
