You are not logged in.

#1 2007-02-27 01:56:05

karmapolice
Member
Registered: 2007-01-31
Posts: 113

Need help with my .bashrc

Hi I'm trying to customize my prompt but I have weird error/bug. My .bashrc looks like

alias ls='ls --color=auto'
alias grep='grep --color=auto'

#PS1='[\u@\h \W]\$ '

PS1="\e[1m[\e[0;34m\u@\h \e[1;37m\w]\e[0m\$ ";

complete -cf sudo

And the bug is that when I type a long command the text is cut off and it starts to appear in the first column of the same line instead of the next line.

Just look at the screenshot where I typed aaaa... and then it is cut off and the aaa.... appear over my username and host name. Everything is fine if I use the default PS1 string.

Screenshot-Terminal.png

Offline

#2 2007-02-27 02:27:31

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Need help with my .bashrc

This isn't really a bash bug.  It has to do with the fact that resizing the terminal doesn't tell bash that it was resized, so it gets the size wrong.  The fix is easy, but causes a very minor performance penalty (you'll never notice it):

shopt -s checkwinsize

This will tell bash to re-check the window size every time it runs a command.

Offline

#3 2007-02-27 02:30:23

karmapolice
Member
Registered: 2007-01-31
Posts: 113

Re: Need help with my .bashrc

But I didn't resize anything. It's the default size

Offline

#4 2007-02-27 07:22:08

Mo
Member
Registered: 2007-01-18
Posts: 92

Re: Need help with my .bashrc

I've got the same problem, and you solution doesn't work sad. The problem only appears, when the color of the prompt is set back to the default color (when the prompt is colored and the text you enter should not be colored).

Offline

#5 2007-02-27 07:37:38

Pajaro
Member
Registered: 2004-04-21
Posts: 884

Re: Need help with my .bashrc

does this happen with konsole? because konsole always had weird treating of lines to me. I ended up getting used to make the window as big as my screen, and used yakuake so that it is easy to access/hide it.

Offline

#6 2007-02-27 08:51:39

Mo
Member
Registered: 2007-01-18
Posts: 92

Re: Need help with my .bashrc

No, for me it happens in urxvt.

Offline

#7 2007-02-27 14:04:30

skymt
Member
Registered: 2006-11-27
Posts: 443

Re: Need help with my .bashrc

Wrap any terminal codes in \[ and \]. Otherwise, bash includes those characters when it calculates the size of your prompt. If my prompt-foo is strong, then this should be what your prompt string should look like:

PS1="\[\e[1m[\e[0;34m\]\u@\h \[\e[1;37m\]\w]\[\e[0m\]\$ "

Offline

#8 2007-02-27 14:59:04

karmapolice
Member
Registered: 2007-01-31
Posts: 113

Re: Need help with my .bashrc

Yes I fixed just before your post.

THX.

Offline

#9 2007-02-27 16:25:04

Mo
Member
Registered: 2007-01-18
Posts: 92

Re: Need help with my .bashrc

Thanks, it works now. I was searching for this for a long time.

Last edited by Mo (2007-02-27 16:25:25)

Offline

Board footer

Powered by FluxBB