petobens / trueline

Fast and extensible bash powerline prompt with true color and fancy icon support
MIT License
385 stars 36 forks source link

Root has issue using trueline #16

Closed Mte90 closed 4 years ago

Mte90 commented 4 years ago

Screenshot_20191005_222044 As you can see in the screen with the root user I get the normal user showed but the color is different. Maybe because I am loading the sh file from the home of the mte90 user? Also I don't know why I get 130 very often as root, maybe is a PID?

petobens commented 4 years ago

Is mte90 a root user? Try running echo ${EUID} and see what you get. Also can you please provide the exacts steps to reproduce your issue? Thanks

Regarding the 130 error code that generally indicates that command received a SIGINT... steps for me to reproduce this are also desirable here.

Mte90 commented 4 years ago

No mte90 is not the root user. That line is from the root user but the trueline file is loaded by the home folder of my user (to avoid duplicates). With the user everything is fine but with root I have this problem.

petobens commented 4 years ago

Can you post the exacts steps for me to reproduce this behaviour? Thanks

Mte90 commented 4 years ago

Investigate a bit, on this line is_root is true https://github.com/petobens/trueline/blob/master/trueline.sh#L74 but the next if is not executed. Seems that on my system the variable $USER is always the basic user (in my case mte90). Maybe because to became root I usually do a su from the mte90 user?

Mte90 commented 4 years ago

About the exit_status I didn't know that was that. I will customize the segments variable to not print it :-)

petobens commented 4 years ago

Seems that on my system the variable $USER is always the basic user (in my case mte90). Maybe because to became root I usually do a su from the mte90 user?

If I only do su then I also have the $USER variable set to my non-root user (pedro in my case). If I do sudo su then the $USER variable is now empty and trueline show root instead. Mmm I don't know what's the proper behaviour here... I believe the color change (to red) might be enough to indicate that we now have super user privileges? I open to change it though if it isn't clear enough

Mte90 commented 4 years ago

I prefer to see root, I don't thrust so much the color, maybe add another option to print the root instead the previous user?

petobens commented 4 years ago

The thing is that in order to actually get/set environment variables for the root user you should indeed run sudo su or su - (see the - flag in man su for details). I think trueline should reflect the active env variables (therefore showing root when $USER is not root is a bit confusing). I need to think a bit more about this though

petobens commented 4 years ago

I stand with my previous comment. Closing now.