Search code examples
shellzshsudosu

Programmatically start su session, run command, and remain at root prompt


Backstory: I SSH into servers where I want to see a personalized root prompt. However, other people log onto these servers and don't necessarily want me changing the prompt.

Question: How can I make a zsh alias/function such that I can log in as a regular user, and typing [my su shortcut] will launch a su session, source .zshrc from my personal home directory, and leave me at a root prompt?


Solution

  • alias mysu="su -c \"ZDOTDIR=$HOME zsh\""
    

    See zsh(1) for details.