X-Git-Url: https://git.distorted.org.uk/~mdw/profile/blobdiff_plain/9bd5ab69d650ab15fa1248cdae3b4c2f55d03665..77619173fdf73ef9835c877f6376bcfc25733c28:/dot/bashrc diff --git a/dot/bashrc b/dot/bashrc index 3053c66..f655756 100644 --- a/dot/bashrc +++ b/dot/bashrc @@ -10,9 +10,38 @@ case ${__mdw_bashrc+t} in t) ;; *) __mdw_bashrc=t -## Fetch the common configuration. +###-------------------------------------------------------------------------- +### Hook implementation. + +__mdw_precmd_hook= __mdw_preexec_hook= +__mdw_running=t + +__mdw_run_precmd_hook () { + __mdw_runhook __mdw_precmd_hook "$@" + __mdw_running=nil +} +__mdw_run_preexec_hook () { + case $__mdw_running in + t) ;; + nil) + __mdw_running=t; + set -- $(history 1); shift + __mdw_runhook __mdw_preexec_hook "$*" + ;; + esac +} + +PROMPT_COMMAND=__mdw_run_precmd_hook +trap __mdw_run_preexec_hook DEBUG + +###-------------------------------------------------------------------------- +### Common shell configuration. + . "$HOME/.shell-rc" +###-------------------------------------------------------------------------- +### Other preliminaries. + ## If we've not run the main profile yet, we should do that first. It sets ## up things we rely on. Also, if there's a system script, we should run ## that too. @@ -41,18 +70,11 @@ __mdw_set_prompt_hacks () { host='\h' dir=' \w' } -__mdw_before_cmd_hack () { - set -- $(history 1); shift - __mdw_preexec "$*" -} - ## Only bother if the shell is interactive. if [ -t 0 ]; then PROMPT_DIRTRIM=5 __mdw_source_if_exists /usr/lib/git-core/git-sh-prompt __mdw_set_prompt_pieces - PROMPT_COMMAND=__mdw_precmd - PS0="\$(__mdw_before_cmd_hack)" fi ###--------------------------------------------------------------------------