Make your enter key magical by binding a Zsh command to it
Based on magic-enter.
You can define your own magic-enter
commands using the following zstyles.
zstyle -s ':zshzoo:magic-enter' command 'ls -laFh .'
zstyle -s ':zshzoo:magic-enter' git-command 'git status -sb .'
You can also define your own magic-enter-cmd
function. Whatever it prints is what will be run when no other command is given. You can use this if you want to extend the command beyond just looking for a git repo.
function magic-enter-cmd {
if [[ -n "$$VIRTUAL_ENV" ]]; then
echo "python3 --version"
else
echo "ls -laFh ."
fi
}
To install using a Zsh plugin manager, add the following to your .zshrc
- antidote:
antidote bundle zshzoo/magic-enter
- zcomet:
zcomet load zshzoo/magic-enter
- zgenom:
zgenom load zshzoo/magic-enter
- znap:
znap source zshzoo/magic-enter
To install manually, first clone the repo:
git clone https://github.com/zshzoo/magic-enter ${ZDOTDIR:-~}/.zplugins/magic-enter
Then, in your .zshrc, add the following line:
source ${ZDOTDIR:-~}/.zplugins/magic-enter/magic-enter.zsh
To install with Prezto, first clone the repo from an interactive Zsh session:
# make sure your $ZPREZTODIR is set
ZPREZTODIR=${ZPREZTODIR:-~/.zprezto}
# clone the repo to a prezto contrib dir
git clone https://github.com/zshzoo/magic-enter $ZPREZTODIR/contrib/magic-enter/external
# set up the contrib
echo "source \${0:A:h}/external/magic-enter.plugin.zsh" > $ZPREZTODIR/contrib/magic-enter/init.zsh
Then, add the plugin to your Prezto plugins list in .zpreztorc
zstyle ':prezto:load' pmodule \
... \
magic-enter \
...