Re: bash: $PS1 does not update with popd

From: Icarus Sparry (usenet_at_icarus.freeuk.com)
Date: 05/19/05


Date: Thu, 19 May 2005 17:04:43 GMT

On 2005-05-19, linq936@hotmail.com <linq936@hotmail.com> wrote:
> Hi,
> Here is how I define the prompt,
>
> export PS1=`echo ${HOST}`":"`echo $cwd|sed -e "s/^.*tmp_mnt//" -e
> "s/^.*users*/\/user/" -e "s/^.*${USER}\/*//"`">"
>
> This is very good in that the prompt updates when I change directory.
>
> But now I find that this does not work when I use "pushd" and "popd"
> commands. After the "popd" command, prompt does not update.
>
> Do you know how to fix this?

This code will only work if you have 'cd' defined (probably as a
function, but maybe as an alias) to update the 'cwd' variable. I can not
work out exactly what you are trying to do with your 'sed' commands,
but they are almost certainly not doing what you expect. Try the
following 2 commands

        mkdir -p ~/tmp/otherusers/x
        cd ~/tmp/otherusers

and see if the prompt is 'correct'

If you replace cwd with PWD in your code, it might work better. Or you
might try

PS1='\h:\W>'

and see if that is good enough. If not they send us the output of

        type cd pushd popd
        echo $PROMPT_COMMAND

and if the variable PROMPT_COMMAND references any other functions, the
value of them as well.



Relevant Pages

  • bash: $PS1 does not update with popd
    ... This is very good in that the prompt updates when I change directory. ... commands. ... After the "popd" command, prompt does not update. ...
    (comp.unix.shell)
  • Re: Dropping DTR to access command mode during ppp session
    ... Then at the root prompt, ... Type your AT commands, and then hit ~. ... >According to the modem manual, dropping DTR will put the modem into ... Here's what I worry about. ...
    (freebsd-questions)
  • Re: Process Idle Time
    ... I basically want to know if the prompt is busy in any way. ... >> file in turn invokes several executables. ... it depends on what sorts of commands are used in the BAT or CMD file. ...
    (microsoft.public.win32.programmer.kernel)
  • [opensuse] Help installing openSUSE 10.2
    ... of the boot commands identified as runlevel 3. ... On boot screen use Other Options and enter 3 and press Enter to ... boot into runlevel 3, which is text mode with network. ... If computer gives you text mode login prompt enter user name, ...
    (SuSE)
  • RE: can someone help me with error code: 0x80070715? I cant update wi
    ... The specified resource type cannot be found in the image file. ... Try installing the latest Version of the Windows Update Agent by ... IF this is Vista you and you need to run the commands from a Command ... Prompt, locate 'cmd' from Start Search and then *right* click it, choose ...
    (microsoft.public.windowsupdate)