|
|
|
|
|
by aug-riedinger
2702 days ago
|
|
Probably too late to get some visibility, but I love this: function my-accept-line() {
# check if the buffer does not contain any words
if [ ${#${(z)BUFFER}} -eq 0 ]; then
# put newline so that the output does not start next
# to the prompt
echo
# check if inside git repository
if git rev-parse --git-dir > /dev/null 2>&1 ; then
# if so, execute `git status'
git status
else
# else run `ls'
ls -l
fi
fi
# in any case run the `accept-line' widget
zle .accept-line
}
# create a widget from `my-accept-line' with the same name
zle -N accept-line my-accept-line
# rebind Enter, usually this is `^M'
bindkey '^M' accept-line
This replaces `enter` (empty command line), with either `ls` or `git status` if in a git repository.This beautifully works as expected, I never got any bug because of this (as this could be expected for low level aliasing), and it does exactly what I'd expect: get current status of the current folder. Now typing `git status` elsewhere is such a pain! |
|