diff options
author | Marc Cornellà <marc.cornella@live.com> | 2019-05-08 20:40:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-08 20:40:36 +0200 |
commit | 0232ac4bb1cb64b5bfaa7e5fc979d6f7ab23e534 (patch) | |
tree | 946d9f8b758ebdd63da96152ca56b154c99068da /plugins/magic-enter/magic-enter.plugin.zsh | |
parent | afb028763cf40fc339e49011b2cba124dc108fcb (diff) | |
parent | ebc700be9b2fa7ae770a644093a5c46a8e323726 (diff) | |
download | zsh-0232ac4bb1cb64b5bfaa7e5fc979d6f7ab23e534.tar.gz zsh-0232ac4bb1cb64b5bfaa7e5fc979d6f7ab23e534.tar.bz2 zsh-0232ac4bb1cb64b5bfaa7e5fc979d6f7ab23e534.zip |
Merge branch 'master' into master
Diffstat (limited to 'plugins/magic-enter/magic-enter.plugin.zsh')
-rw-r--r-- | plugins/magic-enter/magic-enter.plugin.zsh | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/plugins/magic-enter/magic-enter.plugin.zsh b/plugins/magic-enter/magic-enter.plugin.zsh new file mode 100644 index 000000000..8e1859678 --- /dev/null +++ b/plugins/magic-enter/magic-enter.plugin.zsh @@ -0,0 +1,24 @@ +# Bind quick stuff to enter! +# +# Pressing enter in a git directory runs `git status` +# in other directories `ls` +magic-enter () { + + # If commands are not already set, use the defaults + [ -z "$MAGIC_ENTER_GIT_COMMAND" ] && MAGIC_ENTER_GIT_COMMAND="git status -u ." + [ -z "$MAGIC_ENTER_OTHER_COMMAND" ] && MAGIC_ENTER_OTHER_COMMAND="ls -lh ." + + if [[ -z $BUFFER ]]; then + echo "" + if git rev-parse --is-inside-work-tree &>/dev/null; then + eval "$MAGIC_ENTER_GIT_COMMAND" + else + eval "$MAGIC_ENTER_OTHER_COMMAND" + fi + zle redisplay + else + zle accept-line + fi +} +zle -N magic-enter +bindkey "^M" magic-enter |