bash support for a few zsh hooks

This commit is contained in:
Loic Nageleisen 2013-12-13 13:53:37 +01:00
parent e1adf97cfe
commit 94be104bc9
2 changed files with 33 additions and 3 deletions

27
bash/ext Normal file
View file

@ -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 $@; }