Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
78e7ec21
Commit
78e7ec21
authored
Jul 01, 2018
by
Shadab Zafar
Committed by
Marc Cornellà
Jul 01, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add magic-enter plugin (#4082)
* Added magic-enter plugin To bind commonly used tasks to the enter key * Allow the magic-enter commands to be modified by the user
parent
2de926aa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
+38
-0
Readme.md
plugins/magic-enter/Readme.md
+14
-0
magic-enter.plugin.zsh
plugins/magic-enter/magic-enter.plugin.zsh
+24
-0
No files found.
plugins/magic-enter/Readme.md
0 → 100644
View file @
78e7ec21
## Magic Enter
**Maintainer:**
[
@dufferzafar
](
https://github.com/dufferzafar
)
Makes your enter key magical, by binding commonly used commands to it.
You can set the commands to be run in your .zshrc, before the line containing plugins!
```
bash
MAGIC_ENTER_GIT_COMMAND
=
'git status -u .'
MAGIC_ENTER_OTHER_COMMAND
=
'ls -lh .'
plugins
=(
magic-enter
)
```
plugins/magic-enter/magic-enter.plugin.zsh
0 → 100644
View file @
78e7ec21
# 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment