Subject: FVWM: bash PS1 fvwm2 titlebar problem

From: Martin Novak <[email-masked]>
Date: Fri, 11 May 2001 21:36:49 +0200

hi,
i'm new here, so hello everybody.

could anyone try to reproduce this behaviour, or give me a hint?

below is the .bash_profile part which defines my PS1.
it works fine, but fvwm seems to have a problem with the titlebar, when a
new xterm is opened. the titlebar simply says 'xterm', until i change to
some directory for the first time. from then on it works properly.
with twm the ps1 definition works without problems here.

thanks in advance
martin novak

info:
system:	freebsd 4.3s
bash:	2.05
fvwm:	2.2.5
i've had this behaviour since fbsd 3.x, bash 2.03, fvwm 2.??

.bash_profile part:
...
case $TERM in
    xterm*) TITLEBAR='\[\e]1;\W\a\e]2;\h: ${PWD}\a'
            ;;
    *)      TITLEBAR=''
            ;;
esac
function prmpt1
{
    local GREEN="\[\e[1;32m\]"
    local   RED="\[\e[1;31m\]"
    local  CYAN="\[\e[1;36m\]"
    local  BLUE="\[\e[1;34m\]"
    local NOCOL="\[\e[0m\]"
    if awk 'BEGIN {"who am i" | getline;\
    if ((match($6, /(:.+\..+)/)) || ($6 == "")) exit 0; else exit 1 }'
        then local HOSTCOL=$BLUE
        else local HOSTCOL=$CYAN
    fi
    if [ `id -u` -eq 0 ]
        then    local USERCOL=$RED
        else    local USERCOL=$GREEN
    fi
PS1="${TITLEBAR}\n\
${USERCOL}[\
${HOSTCOL}\h: ${BLUE}"'${PWD}'\
"${USERCOL}]\
\n${BLUE}\$${NOCOL} "
}
prmpt1

-- 
[email-masked]
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Rob Windsor <[email-masked]>
Date: Fri, 11 May 2001 14:53:43 -0500

> with twm the ps1 definition works without problems here.

[snip...]

You'll need to debug your .bash_profile to find out why "prmpt1" isn't
getting called.  Is anything else in your .bash_profile executing when
you open an xterm?

I also run fun stuff in my xterm title bars, my setup is real simple and
looks like this:

==== .profile ====
# ... stuff above here, irrelevant (set path, etc..)
if [ X"${SHELL}" = X"" ]; then
    echo "SHELL not defined! (Rob msg 1)"
else
    BSHELL="`basename ${SHELL}`" ; export BSHELL
fi

# going interactive!
if [ -f ${HOME}/.profile-login ]; then
    case $- in
        *i*) . ${HOME}/.profile-login ;;
        *)   # do nothing, really.  ;;
    esac
# feh, sh doesn't know the above
    if [ X"${BSHELL}" = X"sh" ]; then
        go() { . ${HOME}/.profile-login ; }
    fi
fi
==== end of .profile ====
==== .profile-login ====
# ... stuff above here, irrelevant (define aliases, some interactive vars)
case ${BSHELL} in
    sh)
        # irrelevant stuff here
    ;;
    bash)
        set -o emacs
        if [ X"${TERM}" = X"xterm" -o X"${TERM}" = X "xterm-color" ]; then
            if [ X"${UID}" = X"0" ]; then
                PS1=": (r) \h; \[\033]2;-root- \h:\w\007\]"
            else
                PS1=": \h; \[\033]2;\h:\w\007\]"
            fi
        else
            if [ X"${UID}" = X"0" ]; then
                PS1=": (r) \h:\w#; "
            else
                PS1=": \h:\w; "
            fi
        fi
        chfont()  { echo -en "\033]50;$*\007" ; }
        chicon()  { echo -en "\033]1;$*\007" ; }
        chtitle() { echo -en "\033]2;$*\007" ; }
    ;;
    ksh)
        # more stuff, irrelevant
    ;;
    zsh)
        # more stuff, irrelevant
    ;;
    *)  
    echo "wtf!?!?!  I don't know what you are running."
    ;;
esac

if [ ! X"${PS1}" = X"" ]; then
    export PS1
fi

==== end of .profile-login ====

As you can tell, I don't bother with shell-specific dotfiles.

Rob++
----------------------------------------
Internet: [email-masked]                             __o
Life: [email-masked]                    _`\<,_
                                                       (_)/ (_)
The weather is here, wish you were beautiful.
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Martin Novak <[email-masked]>
Date: Fri, 11 May 2001 22:58:06 +0200

> Verily did Martin Novak write:
<snip>

> getting called.  Is anything else in your .bash_profile executing when

thanks for your reply. i'm not sure what you meant by "..not getting
called..". prmpt1 definitely gets called, the problem is the initial update
of the titlebar in fvwm (from 'xterm' to 'host: /some/path'). ps1 is set to
what is defined in the func, but fvwm doesn't use the titlebar value until
the value gets changed (e.g. after i 'cd' somewhere).
to me it seems like some sort of a timing problem, because a 'sleep 1'
after the prmpt1 call does the job...

bye
martin novak

<snip>

---

From: Mikhael Goikhman <[email-masked]>
Date: Fri, 18 May 2001 20:26:42 +0000

> ${HOSTCOL}\h: ${BLUE}"'${PWD}'\

I can't reproduce this neither with fvwm-2.2.5 nor fvwm-2.3.32, window
names are successfully changed from xterm without any cd command.

Use FvwmIdent and/or xwininfo to determine whether a window title that you
see is correct.

Regards,
Mikhael.