Skip to content

Commit ab3b8b8

Browse files
authored
Merge pull request #1979 from gaelicWizard/preexec-histcontrol
preexec: work around upstream mangling of `$HISTCONTROL`
2 parents c90a628 + bdfb987 commit ab3b8b8

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

bash_it.sh

-3
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

plugins/available/xterm.plugin.bash

+5-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ precmd_xterm_title() {
3030
}
3131

3232
preexec_xterm_title() {
33-
set_xterm_title "$(_short-command "${1:-}") {$(_short-dirname)} (${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}})"
33+
local command_line="${BASH_COMMAND:-${1:-}}"
34+
local directory_name short_command
35+
directory_name="$(_short-dirname)"
36+
short_command="$(_short-command "${command_line}")"
37+
set_xterm_title "${short_command} {${directory_name}} (${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}})"
3438
}
3539

3640
case "${TERM:-dumb}" in

vendor/init.d/preexec.bash

+24-2
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)