I'm describing what to do in bash
. I don't know zsh
well enough to describe what to do there.
I think your problem is on the left side of the equal sign. Use a unique, short and easy to remember name for the alias (no spaces). Also there should be no spaces around the equal sign.
Otherwise it is easy to include sudo
into an alias, just put it in the definition of the alias. I can show an example from my aliases in ~/.bashrc
,
alias uc='sudo umount /dev/sdc*'
(to unmount all partitions on the drive /dev/sdc
)
I might have suggested sv
as the name of the alias, but there is a standard tool with that name, so maybe sev
, acronym for 'sudo -E nvim', will work better.