|Bash Prompt HOWTO: $Revision: 0.89 $, $Date: 2001/08/22 00:57:34 $|
|Prev||Chapter 9. Loading a Different Prompt||Next|
You can change the prompt in your current terminal (using the example "elite" function above) by typing source elite followed by elite (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 unset elite 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 can change environment variables of your current shell are environment functions. The bashprompt package puts a function called callbashprompt 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. callbashprompt wasn't intended to be used this way, and has no error checking, but if you keep that in mind, it works quite well.
Закладки на сайте
Проследить за страницей
Created 1996-2023 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру