A lot of my workflow involves using a sudo interactive session (sudo -i
) as a service user that is able to run certain things that my personal username can't. When I do this, I like to preserve my PS1 variable and some other little bash niceties. As I can't modify the service user's .bashrc
, I have a script set up in my home directory to export this as I like it. For example, my workflow might look like:
ssh me@remote
sudo -i -u service_user
. /home/me/ps1.sh
*service user commands here*
exit
I'd like to roll the sudo command and sourcing the PS1 script into one command. My thought was to use something like sudo -i -u service_user -c sh ". /home/me/ps1.sh"
, which will pass the command in - the problem is that the session will immediately exit after the command runs, rather than hanging in interactive mode. Short of requesting the admin allow the PS1 variable to be preserved through sudo, is there anything I can do?