Zshell aliases like !gst inside vim?
Asked Answered
E

2

11

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

Embryonic answered 26/2, 2014 at 23:14 Comment(0)
D
8

Try

:set shell=zsh\ -l

And put the alias setting to ~/.zshenv

Here is the similar question terminal vim not loading .zshrc.

Dion answered 27/2, 2014 at 0:7 Comment(5)
In that link they just suggest set shell=zsh\ -i, which I tried, but it resulted in suspended (tty output) unfortunately.Embryonic
@Embryonic get rid of the -i argument. This tells zsh to run as an interactive program which it is not (when run from inside vim). However the aliases might not be there depending on how your rc scripts are sourced... (I do not know zsh well enough to comment on if your aliases will be sourced in a non interactive shell)Syncretize
Taking away the -i argument does not seem to work either. Maybe you are right about my rc scripts not being sourced, but unfortunately I am a beginner and have no idea how to check.Embryonic
@Embryonic try to put alias in ~/.zshenvDion
@TimGreen Awesome, that worked! Please add it to your answer and I'll check it. ThanksEmbryonic
S
2

@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.

Sainthood answered 30/1, 2015 at 11:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.