Is there a way to run my zshell aliases inside vim, with the output going to a new split?
I'm using oh-my-zsh's git aliases like gst
, and I am unable to do :!gst
inside vim.
Thanks
Defining Aliases Aliases in zsh share the common alias builtin command from other shells. Aliases are handy for saving time when typing commands. If they are not "global aliases" then they only work at the beginning of a command prompt (more below). Typical aliases are used for commands such as: alias g=git.
zshrc file free of clutter. Place the aliases in their own file, ie: . zsh_aliases. You can also create a file for other things, like app shortcuts.
To set up a simple alias, edit the ~/. zshrc file using your text editor and add an alias at the bottom. It is good to keep all your aliases in a single section of the file to avoid confusion and ease of edit. alias ginit="git init ."
@tim-green is right!
As the man page says:
Commands are then read from $ZDOTDIR/.zshenv. If the shell is a login shell, commands are read from /etc/zprofile and then $ZDOTDIR/.zprofile. Then, if the shell is interactive, commands are read from /etc/zshrc and then $ZDOTDIR/.zshrc.
Since you don't want interactive shell in vim (using !
at least), your only solution is to add (or source
) your aliases inside ~/.zshenv
.
As simple as that!
EDIT: no other modification is required, except to put:
set shell=/bin/zsh
in your vimrc.
Try
:set shell=zsh\ -l
And put the alias setting to ~/.zshenv
Here is the similar question terminal vim not loading .zshrc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With