Skip to content

Commit 9ce199c

Browse files
committed
preexec: set options before load
By setting `__bp_delay_install`, we avoid any immediate initialization at all. We then override two troublesome functions before calling `__bp_install_after_session_init()`. The `__bp_install_after_session_init()` function doesn't enable the DEBUG trap, just sets `$PROMPT_COMMAND` to include `__bp_install()`, so the actual final `$PROMPT_COMMAND` is not finished, and DEBUG trap set, until after the first prompt is displayed.
1 parent 2d1bd82 commit 9ce199c

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

bash_it.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,3 @@ if ! _command_exists reload && [[ -n "${BASH_IT_RELOAD_LEGACY:-}" ]]; then
155155
;;
156156
esac
157157
fi
158-
159-
# Disable trap DEBUG on subshells - https://github.com/Bash-it/bash-it/pull/1040
160-
set +T

vendor/init.d/preexec.bash

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
11
# shellcheck shell=bash
2-
# shellcheck disable=1090
3-
source "${BASH_IT}"/vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh
2+
# shellcheck disable=SC2034
3+
#
4+
# Load the `bash-preexec.sh` library, and define helper functions
5+
6+
## Prepare, load, fix, and install `bash-preexec.sh`
7+
8+
# Disable immediate `$PROMPT_COMMAND` modification
9+
__bp_delay_install="delayed"
10+
11+
# shellcheck source-path=SCRIPTDIR/../github.com/rcaloras/bash-preexec
12+
source "${BASH_IT?}/vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh"
13+
14+
# Block damanaging user's `$HISTCONTROL`
15+
function __bp_adjust_histcontrol() { :; }
16+
17+
# Don't fail on readonly variables
18+
function __bp_require_not_readonly() { :; }
19+
20+
# Disable trap DEBUG on subshells - https://github.com/Bash-it/bash-it/pull/1040
21+
__bp_enable_subshells= # blank
22+
set +T
23+
24+
# Modify `$PROMPT_COMMAND` now
25+
__bp_install_after_session_init

0 commit comments

Comments
 (0)