nojhan/liquidprompt — pull request #120 by augmentedfourth (2013-03-14 17:21:06+00:00)
Title: Handle remote sessions that have changed user

Previously, if you were connected via SSH but had changed user with
su/sudo, the _lp_connection function would report you as being connected
via telnet. Now, if the parent process of your shell is 'su' or 'sudo',
it sets the hostname to the color LP_COLOR_SU (default: bold yellow).

This is probably only useful for people who have installed liquidprompt
in a global location and run it with a globally-accessible shell config
(/etc/profile or similar). But since there's already code to handle a
current user of 'root', I assume this has already happened.

It may be prudent to use the parent-process checking code for telnet
checking as well (rather than the 'who am i | sed') method, but I didn't
want to reach too far into existing code... plus, I don't have any servers
with telnetd running to test.

(Assistance from Gilles in http://unix.stackexchange.com/questions/9605/how-can-i-detect-if-the-shell-is-controlled-from-ssh)