mirror of
https://github.com/lloeki/dotfiles.git
synced 2025-12-06 07:24:39 +01:00
bash support for a few zsh hooks
This commit is contained in:
parent
e1adf97cfe
commit
94be104bc9
2 changed files with 33 additions and 3 deletions
27
bash/ext
Normal file
27
bash/ext
Normal 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 $@; }
|
||||
Loading…
Add table
Add a link
Reference in a new issue