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

Re: [OT] How to add fortune output to terminal



Bob Proulx wrote:
> s. keeling wrote:
> > Another common practice is to set PS1 in .bash_profile, then call
> > .bashrc from .bash_profile.
> >  if [ ! -z "$PS1" ]; then
> 
> The PS1 is set by default for interactive shells and not set for
> non-interactive shells.  So the test for $PS1 works without needing to
> set it.  This is in the default Debian /etc/skel/.bashrc too.
> 
> > The intent being to not clutter up the environment any more than is
> > necessary.
> 
> Note: Some versions of bash read the .bashrc when it determines that
> it is started over a remote shell.  By splitting the .bashrc into an
> interactive and non-interactive section then aliases can be loaded
> over a remote shell and made available to the command while not
> breaking things for a non-interactive environment.  Not that I would
> advocate doing that.  The feature was removed from the bash upstream
> due to various problems.  Debian Etch has patches specifically for
> this situation.  See /usr/share/doc/bash/README.Debian.gz .

Another way to do this is:

if [ -n "$PS1" -a "$TERM" != "dumb" ]; then
  # aliases and the like for interactive use
else
  # non-intreactive
fi

TERM=dumb is set by dumb terminal emulations such as M-x shell in Emacs,
in case you wonder.  Colour definitions should be outside.

Regards,

	Joey

-- 
Let's call it an accidental feature.  -- Larry Wall

Please always Cc to me when replying to me on the lists.


Reply to: