On Sun, Jul 29, at 01:56 David Jensen wrote: > > I suggest. > 1). > Lose /etc/extra-prompt.sh. > 2). > Lose export for PS1. > 3). > Use: > > NORMAL="\[\e[0m\]" > RED="\[\e[1;31m\]" > GREEN="\[\e[1;32m\]" > if [[ ${EUID} == 0 ]] ; then > PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL" > else > PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL" > fi >
Thanks a lot David, Attached is a diff with your suggestions. With this chance, I also updated the X.sh script (/X11R6/X11R7). Please review it and as always suggestions are welcomed. -- Ag
Index: postlfs/config/profile.xml =================================================================== --- postlfs/config/profile.xml (revision 6988) +++ postlfs/config/profile.xml (working copy) @@ -140,9 +140,17 @@ # Setup some environment variables. export HISTSIZE=1000 export HISTIGNORE="&:[bf]g:exit" -#export PS1="[EMAIL PROTECTED] \w]\\$ " -export PS1='[EMAIL PROTECTED]:\w\$ ' +# Setup a red prompt for root and a green one for users. +NORMAL="\[\e[0m\]" +RED="\[\e[1;31m\]" +GREEN="\[\e[1;32m\]" +if [[ $EUID == 0 ]] ; then + PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL" +else + PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL" +fi + for script in /etc/profile.d/*.sh ; do if [ -r $script ] ; then . $script @@ -281,47 +289,28 @@ <primary sortas="e-etc-profile.d-X.sh">/etc/profile.d/X.sh</primary> </indexterm> - <para>If <application>X</application> is installed, the <envar>PATH</envar> - and <envar>PKG_CONFIG_PATH</envar> variables are also updated.</para> + <para>If <application>X</application> is installed in + <filename class="directory">/usr/X11R7</filename> directory, the + <envar>PATH</envar> and <envar>PKG_CONFIG_PATH</envar> variables are also + updated. <emphasis>Note</emphasis>: Consult the <xref linkend="xorg7"/> or + the <xref linkend="xfree86"/> pages of the Book, and substitute /usr/X11R7 + with the choosen <envar>XORG_PREFIX</envar> for <application>Xorg</application>, + and the <envar>ProjectRoot</envar> in the case of <application>XFree86</application>. + </para> <screen role="root"><userinput>cat > /etc/profile.d/X.sh << "EOF" -<literal>if [ -x /usr/X11R6/bin/X ]; then - pathappend /usr/X11R6/bin +<literal>if [ -x /usr/X11R7/bin/X ]; then + pathappend /usr/X11R7/bin fi -if [ -d /usr/X11R6/lib/pkgconfig ] ; then - pathappend /usr/X11R6/lib/pkgconfig PKG_CONFIG_PATH +if [ -d /usr/X11R7/lib/pkgconfig ] ; then + pathappend /usr/X11R7/lib/pkgconfig PKG_CONFIG_PATH fi</literal> EOF</userinput></screen> </sect3> - <sect3 id="extra-prompt.sh"> - <title>/etc/profile.d/extra-prompt.sh</title> - - <indexterm zone="postlfs-config-profile extra-prompt.sh"> - <primary sortas="e-etc-profile.d-prompt.sh">/etc/profile.d/extra-prompt.sh</primary> - </indexterm> - - <para>This script shows an example of a different way of setting the - prompt. The normal variable, <envar>PS1</envar>, is supplemented by - <envar>PROMPT_COMMAND</envar>. If set, the value of - <envar>PROMPT_COMMAND</envar> is executed as a command prior to issuing - each primary prompt. The sequence \e is an ESC character. \a is a - BEL character. For a reference on <command>xterm</command> escape - sequences, see <ulink - url="http://rtfm.etla.org/xterm/ctlseq.html"/>.</para> - -<screen role="root"><userinput>cat > /etc/profile.d/extra-prompt.sh << "EOF" -<literal>PROMPT_COMMAND='echo -ne "[EMAIL PROTECTED] : ${PWD}\e[0m\a"' -export PROMPT_COMMAND</literal> -EOF</userinput></screen> - - <para>The escape sequences above are BOLD, NORMAL, and BEL.</para> - - </sect3> - <sect3 id="i18n.sh"> - <title>'/etc/profile.d/i18n.sh'</title> + <title>/etc/profile.d/i18n.sh</title> <indexterm zone="postlfs-config-profile i18n.sh"> <primary sortas="e-etc-profile.d-i18n.sh">/etc/profile.d/i18n.sh</primary> @@ -384,8 +373,14 @@ # PS1 Environment Variable for a great case study behind this script # addendum.] -#export PS1="[EMAIL PROTECTED] \w]\\$ " -export PS1='[EMAIL PROTECTED]:\w\$ ' +NORMAL="\[\e[0m\]" +RED="\[\e[1;31m\]" +GREEN="\[\e[1;32m\]" +if [[ $EUID == 0 ]] ; then + PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL" +else + PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL" +fi # End /etc/bashrc</literal> EOF</userinput></screen>
-- http://linuxfromscratch.org/mailman/listinfo/blfs-dev FAQ: http://www.linuxfromscratch.org/blfs/faq.html Unsubscribe: See the above information page