180 lines
3.5 KiB
HTML
180 lines
3.5 KiB
HTML
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>Setting the PS? Strings Permanently</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="Bash and Bash Prompts"
|
|
HREF="c141.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="Bash Prompt Escape Sequences"
|
|
HREF="bash-prompt-escape-sequences.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="Bash Programming and Shell Scripts"
|
|
HREF="c189.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="bash-prompt-escape-sequences.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
>Chapter 2. Bash and Bash Prompts</TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="c189.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="SECT1"
|
|
><H1
|
|
CLASS="SECT1"
|
|
><A
|
|
NAME="SETPS"
|
|
></A
|
|
>2.6. Setting the PS? Strings Permanently</H1
|
|
><P
|
|
>Various people and distributions set their PS? strings in different places.
|
|
The most common places are /etc/profile, /etc/bashrc, ~/.bash_profile, and
|
|
~/.bashrc . Johan Kullstam (johan19 at idt dot net) writes: </P
|
|
><A
|
|
NAME="AEN183"
|
|
></A
|
|
><BLOCKQUOTE
|
|
CLASS="BLOCKQUOTE"
|
|
><P
|
|
>the PS1 string should be set in .bashrc. this is because
|
|
non-interactive bashes go out of their way to unset PS1. the bash man
|
|
page tells how the presence or absence of PS1 is a good way of knowing
|
|
whether one is in an interactive vs non-interactive (ie script) bash
|
|
session.</P
|
|
><P
|
|
>the way i realized this is that startx is a bash script. what this
|
|
means is, startx will wipe out your prompt. when you set PS1 in
|
|
.profile (or .bash_profile), login at console, fire up X via startx,
|
|
your PS1 gets nuked in the process leaving you with the default
|
|
prompt.</P
|
|
><P
|
|
>one workaround is to launch xterms and rxvts with the -ls option to
|
|
force them to read .profile. but any time a shell is called via a
|
|
non-interactive shell-script middleman PS1 is lost. system(3) uses sh
|
|
-c which if sh is bash will kill PS1. a better way is to place the
|
|
PS1 definition in .bashrc. this is read every time bash starts and is
|
|
where interactive things - eg PS1 should go.</P
|
|
><P
|
|
>therefore it should be stressed that PS1=..blah.. should be in .bashrc
|
|
and not .profile.</P
|
|
></BLOCKQUOTE
|
|
><P
|
|
>I tried to duplicate the problem he explains, and encountered a
|
|
different one: my PROMPT_COMMAND variable (which will be introduced later)
|
|
was blown away. My knowledge in this area is somewhat shaky, so I'm going
|
|
to go with what Johan says.</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="bash-prompt-escape-sequences.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="c189.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>Bash Prompt Escape Sequences</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="c141.html"
|
|
ACCESSKEY="U"
|
|
>Up</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Bash Programming and Shell Scripts</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |