diff --git a/plugins/magic-enter/Readme.md b/plugins/magic-enter/Readme.md new file mode 100644 index 000000000..b5b27bec9 --- /dev/null +++ b/plugins/magic-enter/Readme.md @@ -0,0 +1,5 @@ +## Magic Enter + +**Maintainer:** [@dufferzafar](https://github.com/dufferzafar) + +Makes your enter key magical, by binding commonly used commands to it. diff --git a/plugins/magic-enter/magic-enter.plugin.zsh b/plugins/magic-enter/magic-enter.plugin.zsh new file mode 100644 index 000000000..2989a30a9 --- /dev/null +++ b/plugins/magic-enter/magic-enter.plugin.zsh @@ -0,0 +1,19 @@ +# Bind quick stuff to enter! +# +# Pressing enter in a git directory runs `git status` +# in other directories `ls` +magic-enter () { + if [[ -z $BUFFER ]]; then + echo "" + if git rev-parse --is-inside-work-tree &>/dev/null; then + git status -u . + else + ls -lh + fi + zle redisplay + else + zle accept-line + fi +} +zle -N magic-enter +bindkey "^M" magic-enter