summaryrefslogtreecommitdiff
path: root/src/shell-integration/bash/bash-preexec.sh
AgeCommit message (Collapse)Author
2025-08-03bash: upgrade to bash-preexec 0.6.0Jon Parise
https://github.com/rcaloras/bash-preexec/releases/tag/0.6.0 This is a small update for us because we've been using a patched version of this script in Ghostty for some time, and the 0.6.0 release includes most of the local changes we made as part of maintaining and improving our bash shell integration. - https://github.com/rcaloras/bash-preexec/pull/167 - https://github.com/rcaloras/bash-preexec/pull/170 We continue to maintain one local HISTCONTROL-related modification (#2478). There are a few upstream conversations related to HISTCONTROL that might eliminate the need for this local patch, so we may revisit that in the future.
2025-01-16bash: improve prior_trap processing (#5142)Mitchell Hashimoto
We use `trap` to bootstrap our installation function (__bp_install). We remove our code upon first execution but need to restore any preexisting trap calls. We previously used `sed` to process the trap string, but that had two downsides: 1. `sed` is an external command dependency. It needs to exist on the system, and we need to invoke it in a subshell (which has some runtime cost). 2. The regular expression pattern was imperfect and didn't handle trickier cases like `'` characters in the trap string: $ (trap "echo 'hello'" DEBUG; trap -p DEBUG) hello trap -- 'echo '\''hello'\''' DEBUG This change removes the dependency on `sed` by locally evaluating the trap string and extracting any prior trap. This works reliably because we control the format our trap string, which looks like this (with newlines expanded): __bp_trap_string="$(trap -p DEBUG)" trap - DEBUG __bp_install Upstream: https://github.com/rcaloras/bash-preexec/pull/170
2025-01-16bash: improve prior_trap processingJon Parise
We use `trap` to bootstrap our installation function (__bp_install). We remove our code upon first execution but need to restore any preexisting trap calls. We previously used `sed` to process the trap string, but that had two downsides: 1. `sed` is an external command dependency. It needs to exist on the system, and we need to invoke it in a subshell (which has some runtime cost). 2. The regular expression pattern was imperfect and didn't handle trickier cases like `'` characters in the trap string: $ (trap "echo 'hello'" DEBUG; trap -p DEBUG) hello trap -- 'echo '\''hello'\''' DEBUG This change removes the dependency on `sed` by locally evaluating the trap string and extracting any prior trap. This works reliably because we control the format our trap string, which looks like this (with newlines expanded): __bp_trap_string="$(trap -p DEBUG)" trap - DEBUG __bp_install
2025-01-16bash: remove sed dependency for history processingJon Parise
We post-process history 1's output to extract the current command. This processing needs to strip the leading history number, an optional * character indicating whether the entry was modified (or a space), and then a space separating character. We were previously using sed(1) for this, but we can implement an equivalent transformation using bash's native parameter expansion syntax. This also results in ~4x reduction in per-prompt command overhead.
2024-10-23bash: stop modifying HISTCONTROL in bash-preexec.shJon Parise
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-05-10shell-integration: update bash-preexec.shJon Parise
This pulls in a fix for `bind -x` bindings unintentionally calling the preexec hook: https://github.com/rcaloras/bash-preexec/pull/152
2023-08-17Simplify Bash Integration (#299)Mitchell Hashimoto
* shell-integration: new bash integration that is much simpler * shell-integration: bash fixes