On Tue, Jan 21, 2020 at 01:44:07PM -0700, Grant Taylor via TUHS wrote:
On 1/20/20 12:40 PM, Theodore Y. Ts'o wrote:
The normal reason why I'm starting subshells
is because I need to
control various environment variables on an ad-hoc basis. It might be
PYTHONPATH, KRB5CCNAME, GPG_AGENT_INFO, LD_LIBRARY_PATH, or some
combination of the above. Back when I was regularly using Kerberos
root/admin bits, I had some hard-coded shell aliases to indicate
explicitly I was in a shell that was using my tytso/root(a)ATHENA.MIT.EDU
or tytso/admin(a)ATHENA.MIT.EDU kerberos tickets.
If I'm understanding you correctly, you used a sub-shell with a modified /
task / process specific environment. Correct?
Correct. And I would often suspend the shell when I didn't need to
use the Kerberos administration credentials, and then go back to it
later when I did need it, and since I was often bouncing back and
forth between the sub-shell and the parent shell, having the SHLVL
displayed in the prompt for non-top-level shells was useful.
For similar reasons, my shell prompt will also display what git branch
I happen to be one. For example:
<tytso@lambda> {/usr/projects/e2fsprogs/e2fsprogs-maint}, level 2 (debian/master)
1001%
Says that I'm on the debian/master git branch, and "level 2" indicates
that I'm in a subshell. (If I'm in a top level shell, no level will
be printed at all.) The prompt also displays the hostname ("lambda"
in this case") which is super-useful to identify remote logins.
- Ted