Artifact on Prompt in Bash

On a fresh install (plus updates) of OpenSuse 11 I recently changed my hostname via Computer->Control Panel->Network settings and am seeing (possibly new, but don’t quote me on that) an “artifact” in my Gnome Terminal prompt.

echo $PS1 yields:

\u@\h>

echo $USERNAME yields:

pholmes

echo $HOSTNAME yields:

davinci

but my prompt reads:

pholmes@davinci26t>

Any ideas as to what’s going on and how to fix it?

FWIW here’s the bash code (apologies to the purists) that I use to print my prompt, which is the last two components of the current working directory:

function _prompt ()
{
    tail=`pwd`
    if test $tail == "/" ; then
        head=$tail # Depth = 0
    else
        head=`dirname $tail`
        if test $head == "/" ; then
            head=$tail # Depth = 1
        else
            head=`dirname $tail`
            if test `dirname $head` == "/" ; then
                head=/`basename $head`/`basename $tail` # Depth = 2
            else
                head=`basename $head`/`basename $tail`  # Depth > 2
            fi
        fi
    fi
    PS1="$head> "
}

PROMPT_COMMAND=_prompt

I’m using bash on openSUSE 11.0

You could use the above as a model to hack something up to your taste.

I did. It worked. Thanks for your help!

If there are any OpenSuse developers out there listening, for what it’s worth it appears that \h and \H are broken (although $HOSTNAME works fine).

Works fine for me. No idea what happened in your case.

I dunno, but it’s also broken in the System Monitor app.

On the one hand, this is a very vanilla install on a Dell Inspiron 530 so I’m a touch nervous about using this OS; I’ve got over 5000 C routines that need to work properly. On the other hand, the reason I’m here is that the Ubuntu C compiler is broken right now and Fedora 9, once it installs, won’t talk to the hard disk it just finished installing to. :shame:

I suspect my major problem is that I remember too well when computers (even ones with windowing systems) just ran. Can I have my SunOS back now? :wink:

Hi
Sounds like your environment may be set via some other application if
you enter


malcolml@kermit-opensuse:~$ env |grep ENV
ENV=/etc/bash.bashrc

Else some thing has been added to /etc/bash.bashrc.local or ~/.bashrc


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.0 x86 Kernel 2.6.25.11-0.1-default
up 3 days 21:56, 4 users, load average: 0.00, 0.05, 0.12
GPU GeForce 6600 TE/6200 TE - Driver Version: 173.14.12

It’s unlikely that a generic GNU utility like bash would be broken in this manner. It’s more likely due to a combination of escape sequences for font effects interacting with your particular terminal type (or wrongly declared terminal type).

I do have a ~/.bashrc (please pardon the antiquity of much of it):

# Sample .bashrc for SuSE Linux
# Copyright (c) SuSE GmbH Nuernberg

# There are 3 different types of shells in bash: the login shell, normal shell
# and interactive shell. Login shells read ~/.profile and interactive shells
# read ~/.bashrc; in our setup, /etc/profile sources ~/.bashrc - thus all
# settings made here will also take effect in a login shell.
#
# NOTE: It is recommended to make language settings in ~/.profile rather than
# here, since multilingual X sessions would not work properly if LANG is over-
# ridden in every subshell.

# Some applications read the EDITOR variable to determine your favourite text
# editor. So uncomment the line below and enter the editor of your choice :-)
#export EDITOR=/usr/bin/vim
#export EDITOR=/usr/bin/mcedit

# For some news readers it makes sense to specify the NEWSSERVER variable here
#export NEWSSERVER=your.news.server

# If you want to use a Palm device with Linux, uncomment the two lines below.
# For some (older) Palm Pilots, you might need to set a lower baud rate
# e.g. 57600 or 38400; lowest is 9600 (very slow!)
#
#export PILOTPORT=/dev/pilot
#export PILOTRATE=115200

test -s ~/.alias && . ~/.alias || true

#
# aliases
#
alias .=pwd
alias ..='cd ..'
#alias change='vi +/\!^ `grep -l \$*`'
alias cls=clear
alias dc=cd
alias df='df -h'
alias du='du -h'
alias h=history
alias l.='ls -dF .[a-zA-Z0-9]*'
alias ll='ls -FCl'
alias ls='ls -FC'
alias mkae=make
alias maek=make
alias pd=pushd
alias asimov='rlogin -l pholmes asimov'
alias tree='find . -type d -print'

#
# environmentals
#
export INFORMIXDIR=/opt/informix
export INFORMIXSERVER=$HOSTNAME
export SQLEXEC=$INFORMIXDIR/lib/sqlrm
export SUNSTUDIODIR=/opt/sun/sunstudio11

export DEVELOP_PATH=$HOME/Develop
export LIBRARY_PATH=.:$DEVELOP_PATH/stochos:$DEVELOP_PATH/disam:$DEVELOP_PATH/cqc:/usr/X11R6/lib:$INFORMIXDIR/lib
export C_INCLUDE_PATH=".:$DEVELOP_PATH/stochos:$DEVELOP_PATH/disam:$DEVELOP_PATH/disam/unix"

export CDPATH=".:~:~/Desktop:~/Downloads:$DEVELOP_PATH"
export PATH=.:$INFORMIXDIR/bin:$SUNSTUDIODIR/bin:$PATH
export MANPATH=$SUNSTUDIODIR/man:${MANPATH:=/usr/share/man}

#
#  because bash \h and \H is screwed up right now
#
function _prompt ()
{
    PS1="\e]2;"`pwd`"\a"$USERNAME"@"$HOSTNAME">"
}
PROMPT_COMMAND=_prompt

FWIW I did change the fonts in the default terminal profile to Monospace 11.

Hi
Informix… had to work with that on Solaris :slight_smile: Anyway I digress, have
a read of the /etc/bash.bashrc file if you create a file called
~/.bashrc.expert it should read your customizations from there. Then if
anything is updated it won’t over write it.

I’m assuming if you su - to root there is no issue and it’s just at a
user level?

I have two systems here running openSUSE 11 and some VM’s on 11 and have
never seen this…


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.0 x86 Kernel 2.6.25.11-0.1-default
up 3 days 23:51, 2 users, load average: 0.24, 0.24, 0.15
GPU GeForce 6600 TE/6200 TE - Driver Version: 173.14.12

I was using Informix/SE for my current app until IBM bought it and changed it into “billions and billions” of versions. Nice app if you needed to get at your data fast (via the underlying C-ISAM) but you wanted your users to have the convenience of SQL.

Ummm…

pholmes@davinci>su
Password: 
davinci26t:/home/pholmes #

For more entertainment:

pholmes@davinci>ksh
pholmes@davinci:/home/pholmes>
pholmes@davinci>zsh

This is the Z Shell configuration function for new users, zsh-newuser-install.
You are seeing this message because you have no zsh startup files
(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
~).  This function can help you with a few settings that should
make your use of the shell easier.

You can:

(q)  Quit and do nothing.  The function will be run again next time.

(0)  Exit, creating the file ~/.zshrc containing just a comment.
     That will prevent this function being run again.

(1)  Continue to the main menu.

--- Type one of the keys in parentheses --- q
pholmes@davinci:~>

Worst part of it is I’m pretty sure that the 26t was default behavior at the original install but, at least for right now, I’m not going to go back and reload this whole mess just to find out.