<HTML ><HEAD ><TITLE >Loading a Different Prompt, Immediately</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Bash Prompt HOWTO" HREF="index.html"><LINK REL="UP" TITLE="Loading a Different Prompt" HREF="c641.html"><LINK REL="PREVIOUS" TITLE="Loading a Different Prompt, Later" HREF="x643.html"><LINK REL="NEXT" TITLE="Loading Different Prompts in Different X Terms" HREF="x664.html"></HEAD ><BODY CLASS="SECT1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Bash Prompt HOWTO: </TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="x643.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 9. Loading a Different Prompt</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="x664.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="AEN655" ></A >9.2. Loading a Different Prompt, Immediately</H1 ><P >You can change the prompt in your current terminal (using the example "elite" function above) by typing <TT CLASS="USERINPUT" ><B >source elite</B ></TT > followed by <TT CLASS="USERINPUT" ><B >elite</B ></TT > (assuming that the elite function file is the working directory). This is somewhat cumbersome, and leaves you with an extra function (elite) in your environment space - if you want to clean up the environment, you would have to type <TT CLASS="USERINPUT" ><B >unset elite</B ></TT > as well. This would seem like an ideal candidate for a small shell script, but a script doesn't work here because the script cannot change the environment of your current shell: it can only change the environment of the subshell it runs in. As soon as the script stops, the subshell goes away, and the changes the script made to the environment are gone. What <EM >can</EM > change environment variables of your current shell are environment functions. The bashprompt package puts a function called <B CLASS="COMMAND" >callbashprompt</B > into your environment, and, while they don't document it, it can be called to load any bashprompt theme on the fly. It looks in the theme directory it installed (the theme you're calling has to be there), sources the function you asked for, loads the function, and then unsets the function, thus keeping your environment uncluttered. <B CLASS="COMMAND" >callbashprompt</B > wasn't intended to be used this way, and has no error checking, but if you keep that in mind, it works quite well. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="x643.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="x664.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Loading a Different Prompt, Later</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="c641.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Loading Different Prompts in Different X Terms</TD ></TR ></TABLE ></DIV ></BODY ></HTML >