You are not logged in.

#1 2010-01-10 22:50:22

lustikus
Member
Registered: 2009-11-10
Posts: 262

[solved]Gentoo Bash Prompt not working in X

Hi

I'm using this .bashrc from AUR:
http://aur.archlinux.org/packages.php?ID=18418 

it is said to be the standard bashrc from gentoo.

It works with xterm, but I now installed urxvt (256 color) and it doesn't work any more, my prompt ist not colored any more.

I'm not familiar with bash scripting, perhaps someone could have a look.
The Problem ist not my .Xdefaults, I tried with an empty one. I also did "source .bashrc".

Last edited by lustikus (2010-01-11 12:24:28)

Offline

#2 2010-01-10 22:57:11

_ThE_MisT_
Member
Registered: 2007-03-04
Posts: 11

Re: [solved]Gentoo Bash Prompt not working in X

after editing ~/.bashrc, did u run "bash" from the command prompt? (without " " )

if not try it! it may help

Last edited by _ThE_MisT_ (2010-01-10 22:58:18)

Offline

#3 2010-01-11 02:52:32

quarkup
Member
From: Portugal
Registered: 2008-09-07
Posts: 497
Website

Re: [solved]Gentoo Bash Prompt not working in X

you must "source" the .bashrc again.

do something as

$ source ~/.bashrc

or simplier
$ . ~/.bashrc


If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is.
Simplicity is the ultimate sophistication.

Offline

#4 2010-01-11 09:08:40

lustikus
Member
Registered: 2009-11-10
Posts: 262

Re: [solved]Gentoo Bash Prompt not working in X

thanks for the replys.

I ran "bash" and sourced the .bashrc again, nothing changes.
In a non-X console I see the colors, so perhaps it's urxvt related?

Offline

#5 2010-01-11 09:10:56

sHyLoCk
Member
From: /dev/null
Registered: 2009-06-19
Posts: 1,197

Re: [solved]Gentoo Bash Prompt not working in X

lustikus

I just copy pasted the code in my bashrc and re-sourced it. It's working for me in urxvt. Can you post the contents of your bashrc? Please put it within code tags.


~ Regards,
sHy
ArchBang: Yet another Distro for Allan to break.
Blog | GIT | Forum (。◕‿◕。)

Offline

#6 2010-01-11 09:47:36

lustikus
Member
Registered: 2009-11-10
Posts: 262

Re: [solved]Gentoo Bash Prompt not working in X

thanks for testing it.

This is my .bashrc. I did not change anything:

# /etc/bash/bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output.  So make sure this doesn't display
# anything or bad things will happen !


# Test for an interactive shell.  There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.

if [[ $- != *i* ]] ; then
    # Shell is non-interactive.  Be done now!
    return
fi

# Bash won't get SIGWINCH if another process is in the foreground.
# Enable checkwinsize so that bash will check the terminal size when
# it regains control.  #65623
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
shopt -s checkwinsize

# Enable history appending instead of overwriting.  #139609
shopt -s histappend

# Change the window title of X terminals 
case ${TERM} in
    xterm*|rxvt*|Eterm|aterm|kterm|gnome*|interix)
        PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
        ;;
    screen)
        PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
        ;;
esac

use_color=false

# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS.  Try to use the external file
# first to take advantage of user additions.  Use internal bash
# globbing instead of external grep binary.
safe_term=${TERM//[^[:alnum:]]/?}   # sanitize TERM
match_lhs=""
[[ -f ~/.dir_colors   ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
[[ -z ${match_lhs}    ]] \
    && type -P dircolors >/dev/null \
    && match_lhs=$(dircolors --print-database)
[[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true

if ${use_color} ; then
    # Enable colors for ls, etc.  Prefer ~/.dir_colors #64489
    if type -P dircolors >/dev/null ; then
        if [[ -f ~/.dir_colors ]] ; then
            eval $(dircolors -b ~/.dir_colors)
        elif [[ -f /etc/DIR_COLORS ]] ; then
            eval $(dircolors -b /etc/DIR_COLORS)
        fi
    fi

    if [[ ${EUID} == 0 ]] ; then
        PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
    else
        PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
    fi

    alias ls='ls --color=auto'
    alias grep='grep --colour=auto'
else
    if [[ ${EUID} == 0 ]] ; then
        # show root@ when we don't have colors
        PS1='\u@\h \W \$ '
    else
        PS1='\u@\h \w \$ '
    fi
fi

# Try to keep environment pollution down, EPA loves us.
unset use_color safe_term match_lhs

I also made a screenshot with xterm and urxvt in comparison:

201001111138321280x1024.th.png

Offline

#7 2010-01-11 11:02:18

Ultraman
Member
Registered: 2009-12-24
Posts: 242

Re: [solved]Gentoo Bash Prompt not working in X

Somehow your urxvt does not enable color, so the code falls back to

use_color=false

Which makes

if ${use_color} ; then

jump over to

else
    if [[ ${EUID} == 0 ]] ; then
        # show root@ when we don't have colors
        PS1='\u@\h \W \$ '
    else
        PS1='\u@\h \w \$ '
    fi
fi

which does not contain color.

Perhaps it is some urxvt setting that you should change so it presents itself als a color terminal instead of a black and white one.

Dirty fix would be to force it like this:
Try changing the use_colors variable to true.
That should make the first "if" statement enter the code contained in it, which is the colorful one.

Last edited by Ultraman (2010-01-11 11:08:06)

Offline

#8 2010-01-11 11:34:11

lustikus
Member
Registered: 2009-11-10
Posts: 262

Re: [solved]Gentoo Bash Prompt not working in X

thanks, your dirty fix works smile

If someone knows a less dirty fix, it'd be welcome as well

Anaways, I think I just use the PS1 String in this file and dump the rest, as I don't even know what it really does..

Offline

#9 2010-01-11 19:56:39

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: [solved]Gentoo Bash Prompt not working in X

Might try specifying urxvt's color depth in .Xdefaults:

URxvt*depth: 32

Offline

Board footer

Powered by FluxBB