I've just moved over to fish shell after years of Bash. I've ported all of my functions over pretty easily except for a very simple one I have called mkroot:

mkroot () {
        sudo bash --rcfile ~/.bashrc;

I use it to open a root shell which is always up to date with my personal environment (so all my familiar shortcuts work).

Is there anyway to replicate this in fish without having to configure root's environment?

Thanks for any tips.

1 Answer 1


It looks like I was getting confused because the behaviour is different on macOS (10.15) and Linux (Debian Bullseye).

On macOS all that is required to sudo a root fish shell with my environment is:

sudo fish

However on Linux that opens a shell with root's environment.

On Linux I can get the behaviour I want by:

sudo -E fish

As a side note, on macOS you can use sudo to open a root shell with root's environment like this:

sudo -H fish

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.