Adding preexec as a vendored library

Added a vendored lib loading routine in bash-it.sh
Added documentation on how to vendor libs in bash-it
Added and fixed plugins using preexec
Added tests for two plugins
Removed the old preexec lib
This commit is contained in:
buhl
2021-01-08 23:51:37 +01:00
parent 5ad497924c
commit 29855ed1e6
12 changed files with 252 additions and 260 deletions

View File

@@ -0,0 +1,16 @@
# shellcheck shell=bash
cite about-plugin
about-plugin 'Alert (BEL) when process ends after a threshold of seconds'
precmd_return_notification() {
export LAST_COMMAND_DURATION=$(($(date +%s) - ${LAST_COMMAND_TIME:=$(date +%s)}))
[[ ${LAST_COMMAND_DURATION} -gt ${NOTIFY_IF_COMMAND_RETURNS_AFTER:-5} ]] && echo -e "\a"
export LAST_COMMAND_TIME=
}
preexec_return_notification() {
[ -z "${LAST_COMMAND_TIME}" ] && export LAST_COMMAND_TIME=$(date +%s)
}
precmd_functions+=(precmd_return_notification)
preexec_functions+=(preexec_return_notification)