Improve Xtrace by hiding output of prompt commands
This commit is contained in:
parent
db76feed3e
commit
42ec31431e
17
bash/.bashrc
17
bash/.bashrc
@ -130,6 +130,23 @@ if [ -f "$HOME/.private_functions" ] && [ -r "$HOME/.private_functions" ]; then
|
|||||||
. "$HOME/.private_functions"
|
. "$HOME/.private_functions"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Preserve the usefulness of set -x by attempting to hide everything that
|
||||||
|
# happens in prompt_command
|
||||||
|
preserve_xtrace() {
|
||||||
|
if grep -q "x" <<< $-; then
|
||||||
|
XTRACE_WAS_SET=1
|
||||||
|
set +x
|
||||||
|
fi
|
||||||
|
} 2>/dev/null
|
||||||
|
preserve_xtrace_reset() {
|
||||||
|
if [ "${XTRACE_WAS_SET}" ]; then
|
||||||
|
set -x
|
||||||
|
unset XTRACE_WAS_SET
|
||||||
|
fi
|
||||||
|
} 2>/dev/null
|
||||||
|
|
||||||
|
PROMPT_COMMAND="preserve_xtrace; $PROMPT_COMMAND; preserve_xtrace_reset"
|
||||||
|
|
||||||
if $(which direnv &> /dev/null); then
|
if $(which direnv &> /dev/null); then
|
||||||
eval "$(direnv hook bash)"
|
eval "$(direnv hook bash)"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user