From 94be104bc9c7a217487feeb29cbf6025ce08d758 Mon Sep 17 00:00:00 2001 From: Loic Nageleisen Date: Fri, 13 Dec 2013 13:53:37 +0100 Subject: [PATCH] bash support for a few zsh hooks --- bash/ext | 27 +++++++++++++++++++++++++++ bash/rc | 9 ++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 bash/ext diff --git a/bash/ext b/bash/ext new file mode 100644 index 0000000..200e376 --- /dev/null +++ b/bash/ext @@ -0,0 +1,27 @@ +# Make Bash more like Zsh +# derived from http://glyf.livejournal.com/63106.html + +# default: NOOPs +function preexec { :; } +function precmd { :; } +function chpwd { :; } + +__cd_invoke_chpwd() { + builtin cd $@ + chpwd +} + +__preexec_invoke_exec () { + local this_command; + + [ -n "$COMP_LINE" ] && return # completion + [ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] && return # precmd + + this_command=`history 1 | sed -e "s/^[ ]*[0-9]*[ ]*//g"`; + preexec "$this_command" +} + +# set up the hooks +PROMPT_COMMAND="precmd" +trap '__preexec_invoke_exec' DEBUG +cd() { __cd_invoke_chpwd $@; } diff --git a/bash/rc b/bash/rc index 86562e4..2d09134 100644 --- a/bash/rc +++ b/bash/rc @@ -3,14 +3,17 @@ [[ -z "$DOTFILES_ROOT_DIR" ]] && source "$HOME/.dotfilesrc" source $DOTFILES_SHELL_DIR/aliases +source $DOTFILES_BASH_DIR/ext source $DOTFILES_BASH_DIR/prompt source $DOTFILES_BASH_DIR/history source $DOTFILES_BASH_DIR/term_title source $DOTFILES_BASH_DIR/completion -PROMPT_COMMAND="set_prompt;" -PROMPT_COMMAND+="set_term_title;" -#PROMPT_COMMAND+="clear_incomplete_line;" +precmd() { + set_prompt + set_term_title + #clear_incomplete_line +} # Make bash check its window size after a process completes shopt -s checkwinsize