Skip to content

Make Sudo Respect Aliases

Published: at 11:00 PM

For example, I have n alias for nvim.

But this would not work:

sudo n /etc/hosts
sudo: n: command not found

Instead I’d have to type:

sudo nvim /etc/hosts

It can be fixed by putting this in my config:

alias sudo='sudo '

Now, the aliases work with sudo:

sudo n /etc/hosts