mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-03-20 03:13:33 +01:00
Allow the magic-enter commands to be modified by the user
This commit is contained in:
parent
36f1835953
commit
88b6bc9bd3
2 changed files with 16 additions and 2 deletions
|
|
@ -3,12 +3,17 @@
|
|||
# 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
|
||||
git status -u .
|
||||
eval "$MAGIC_ENTER_GIT_COMMAND"
|
||||
else
|
||||
ls -lh
|
||||
eval "$MAGIC_ENTER_OTHER_COMMAND"
|
||||
fi
|
||||
zle redisplay
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue