quick tip #1: including subshell number in prompt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ok -- just a quicky:
if you've ever been in a text editor or another program, shelled out to
another instance of bash,
and forgot the editor was there, you might have logged out of all consoles
or ran ps and found it.
but if you're running screen like i do, i don't log out for weeks, and miss
those editors until i shut down for something.
so, you can add the variable $SHLVL to y our prompt, so your
shell level will be displayed. if you're using screen, and it's not your
login shell, you ight want to:
export SHLVL=0
so that screen's shells will have level 1, and all subshells will have level
2 or more.
otherwise, screen will have level 2, and other subshells will have level 3.
this might apply to ther situations.
now onto the meat of this rather long quick tip:
you can set the variable in your prompt for example:
export PS1="\h:\w [$SHLVL]\$"
so you'll get a prompt like:
fast:~ [1]$
or if you were in a subshell, 1 level deep (from an editor or such):
fast:/directory [2]$
if you have any questions, just ask - i'll help if i can.





[Index of Archives]     [Linux for the Blind]     [Fedora Discussioin]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]
  Powered by Linux