[jhbuild] Set an UNDER_JHBUILD envvar while jhbuild is running



commit d4de4c4467ca1376bd82d34c46f4bc7dcd6809c0
Author: Federico Mena Quintero <federico novell com>
Date:   Thu Jun 17 12:22:11 2010 -0500

    Set an UNDER_JHBUILD envvar while jhbuild is running
    
    This makes it easier to have a custom prompt while you are inside
    a 'jhbuild shell'.
    
    Signed-off-by: Federico Mena Quintero <federico novell com>

 doc/C/jhbuild.xml  |   17 +++++++++++++++++
 scripts/jhbuild.in |    2 ++
 2 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/doc/C/jhbuild.xml b/doc/C/jhbuild.xml
index 764d27a..367c28b 100644
--- a/doc/C/jhbuild.xml
+++ b/doc/C/jhbuild.xml
@@ -1361,6 +1361,23 @@ libgnomecanvas is missing branch definition for gnome-2-20
       <para>This command is equivalent to the following:</para>
 
       <screen><prompt>$</prompt> <userinput>jhbuild run $SHELL</userinput></screen>
+
+      <para>The <envar>UNDER_JHBUILD</envar> environment variable will
+      be set to "true" when this shell is active.  You can use the
+      presence of that variable to customize your shell's prompt to
+      indicate that you indeed are under a jhbuild-controlled shell.
+      For example, you may want to put this in your <filename>.bashrc</filename>:</para>
+
+      <screen>
+	if [ -n "$UNDER_JHBUILD" ]; then
+	    PS1="[jhbuild] $PS1"
+	fi
+      </screen>
+
+      <para>This will make your bash shell display
+      <literal>[jhbuild]</literal> before your normal prompt, making
+      it easier to see which shells are under a jhbuild
+      environment.</para>
     </section>
 
     <section id="command-reference-tinderbox">
diff --git a/scripts/jhbuild.in b/scripts/jhbuild.in
index dc9ccdf..0ab7c6f 100644
--- a/scripts/jhbuild.in
+++ b/scripts/jhbuild.in
@@ -23,6 +23,8 @@ else:
     except ImportError:
         sys.path.insert(0, srcdir)
 
+os.environ['UNDER_JHBUILD'] = 'true'
+
 __builtin__.__dict__['PKGDATADIR'] = pkgdatadir
 __builtin__.__dict__['DATADIR'] = datadir
 __builtin__.__dict__['SRCDIR'] = srcdir



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