Re: OT: Exporting a BASH prompt from a script

From: Shreyas Ananthan (shreyas_at_stallion.umd.edu)
Date: 03/26/05

  • Next message: Maurits van Rees: "Re: apt-get problems."
    To: debian-user@lists.debian.org
    Date: 26 Mar 2005 17:45:47 -0500
    
    

    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.

    -- 
    To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
    

  • Next message: Maurits van Rees: "Re: apt-get problems."

    Relevant Pages

    • Re: problem with exit while using nohup
      ... when you run any command ending with &, it runs in background, that shell does not wait till it gets over and shell prompt is displayed immediately. ... as it is evident, the exit should cause the script to terminate,hence ...
      (comp.unix.shell)
    • Re: Question about script -- make typescript of terminal session
      ... Script started, file is abc.txt ... have anything to do with your prompt? ... - assuming that you are using GNU Bash as your shell - then it will ... about Windows or Cygwin; if it's an NTFS or FAT32 filesystem, ...
      (comp.unix.shell)
    • behavioral change of "read" builtin for sh on 8-CURRENT
      ... This script waits for terminal input for each of the above variables (INT, ... On 8-CURRENT if I hit Enter with no input at the prompt the system seems to ... recognize the newline as input and continues to sit there until I hit Enter ... Enter network interface: ...
      (freebsd-current)
    • behavioral change of "read" builtin for sh on 8-CURRENT
      ... This script waits for terminal input for each of the above variables (INT, ... On 8-CURRENT if I hit Enter with no input at the prompt the system seems to ... recognize the newline as input and continues to sit there until I hit Enter ... Enter network interface: ...
      (freebsd-questions)
    • Re: behavioral change of "read" builtin for sh on 8-CURRENT
      ... This script waits for terminal input for each of the above variables (INT, ... On 8-CURRENT if I hit Enter with no input at the prompt the system seems to ... recognize the newline as input and continues to sit there until I hit Enter ... Enter network interface: ...
      (freebsd-current)