Re: OT: Exporting a BASH prompt from a script

From: Hal Vaughan (hal_at_thresholddigital.com)
Date: 03/27/05

  • Next message: Ron Johnson: "Re: udev howto"
    To: debian-user@lists.debian.org
    Date: Sat, 26 Mar 2005 19:40:36 -0500
    
    

    On Saturday 26 March 2005 05:45 pm, Shreyas Ananthan wrote:
    > Hal Vaughan <hal@thresholddigital.com> writes:
    > > I'm having a strange problem.  I've installed some new systems and I can
    > > change the prompt as I want, but if I write any kind of script, and
    > > change the prompt within the script, it doesn't change the
    > > prompt.  This is even with a short 1 line script that does nothing but
    > > change the prompt.
    > >
    > > Here's the prompt I'm trying to use (which includes escape characters,
    > > which seem to be causing the problem -- bash seems to see them as
    > > commands):
    > >
    > > PS1="\e[35;40m[\u@\h:\W]\\$\e[0m "
    > >
    > > I know my old .bashrc changed the prompt (only PS1), but I don't remember
    > > doing anything other than PS1="{my prompt}" to get it to do that.  Now it
    > > won't work.  I tried to export PS1 so it would be available outside the
    > > script, but export didn't like some of the characters in it.
    > >
    > > So how can I export a prompt I create in a script (like .bashrc) to use
    > > outside the script (in normal command line)?
    >
    > When you run a script, it runs inside a new shell which is terminated
    > when the script is completed. If you want the commands in the script
    > to affect the current shell you want to do
    >
    > debian$ source ./<script name>
    >
    > instead of
    >
    > debian$ ./<script name>
    >
    > Hope that helps.

    I wasn't aware of that point, however, even when I type "source scrptname", it
    still happens.

    I think there's two problems: 1) it won't export the prompt (even when "source
    name" is used), and 2) Bash seems to be interpreting the escaped characters
    as commands.

    Hal


  • Next message: Ron Johnson: "Re: udev howto"

    Relevant Pages

    • Checking for existence of command prior to execution
      ... alone in an interactive shell it works though. ... it will fail if I add ssh to the list of commands which is ... aliased by the tcsh that is calling the above script. ...
      (comp.os.linux.misc)
    • Re: shell scripting while if string length != 0
      ... I'm not a shell guru, but pipelines don't necessarily run in sequence. ... In line 5 of your script, ... the file and wait for new commands, you may need a named pipe. ... To unsubscribe, ...
      (freebsd-questions)
    • Re: unzip | touch | re-zip
      ... Put these commands in a function and all is solved. ... I know next to nothing about Unix shell commands. ... get a zipfile download preparation script in PHP to work on my website. ...
      (comp.unix.shell)
    • Re: Shell Script
      ... Another valuable document to look at it the Advanced Bash Scripting Guide ... Within the script, it will change the directory to /opt, and then exit. ... THIS HAS NO EFFECT ON THE SHELL YOU RUN THIS COMMAND IN. ... Read and execute commands from FILENAME and return. ...
      (linux.redhat)
    • Re: Shell Script
      ... Within the script, it will change the directory to /opt, and then exit. ... THIS HAS NO EFFECT ON THE SHELL YOU RUN THIS COMMAND IN. ... Read and execute commands from FILENAME and return. ...
      (linux.redhat)