There is no general way to achieve this.
Powerline makes use of characters in the Private Use Area of Unicode. I've seen it come as a surprise, again and again, to Powerline (and "nerd fonts") users to learn that Private Use Area really does mean something that does not work the same everywhere, whose meaning is determined entirely by private arrangement.
There is no standard way to determine what glyphs will be rendered for Private Use Area code points, and what private arrangement is in place. There's no way to determine, other than by actually looking at the glyphs or reading the human-readable doco, that a font will have the non-standard glyphs that Powerline expects.
Moreover, there are bitmap fonts that have the non-standard private Powerline glyphs (e.g. Tamzen). So this cannot in the general case be proxied by whether the terminal is a Kernel Virtual Terminal. A KVT might or might not display the non-standard private Powerline glyphs.
Nor can it sensibly be proxied by whether a shell is a login shell. Shells can be login shells on terminal emulators where the fonts have the non-standard private Powerline glyphs (several GUI terminal emulators having the ability to start shells as login shells), as easily as shells can be non-login shells on terminal emulators where the fonts do not have the non-standard private Powerline glyphs (as one can just fork+exec a child shell, or "shell out" from the likes of mailx
or vi
).
You simply have to come up with your own private arrangement. Find some way to mark the terminal login sessions where you have (not) installed this particular meaning for Private Use Area code points. Examples of the sorts of ways that this can be achieved:
- Set an environment variable of your own devising in
getty
, login
, or even the login services for KVT login, and key your shell initialization scripts off that (with the proviso that you need to have administrator access and that you need to maintain this setting in the future as things change).
- Key off the terminal device file name, in some private way (with the proviso that this is significantly complicated when you introduce real terminals, over serial connections, into the mix; or introduce SSH).
- Send an ␅ (U+0005) character and key off what comes back (with the proviso that this has always been user-programmable at the terminal end and may indeed not cause anything to come back).
On the gripping hand …
Of course, the better route is to make your theme use standard characters, and not worry about any of these bodges.
There is no actual need for a Private Use Area code point, as the author of your theme supposes, for a locked padlock. That's standardized at U+1F512 (🔒). There's an unlocked padlock at U+1F513 (🔓).
Maybe this PUA thing will turn out to be a turn-of-the-century fad, and people will return to using U+131B1 (𓆱) for a branch once more. ☺
su
with no options does not run a login shell (but other ways to run it do, for examplesu -
), so if you end up with a login shell aftersu
there's something weird in your configuration.