LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-17-2005, 04:23 PM   #1
rpz
Member
 
Registered: Mar 2005
Posts: 126

Rep: Reputation: 15
bash: Idiot problem, gives me a headache ...


I am trying to fix my bash prompt to the following:
hostname:username hh:mm /current/path $
it worked allright using the following in my bashrc
Code:
export PS1="\e[0;1m\h\e[0;0m:\u \A \w $ "
or at least, so I thought. As it happens ,when I type a very long command line (one that wraps the line), the next line overwrites the first one (like a carriage return with no linefeed in terminal terminology). I think the problem might be due to the nonprintable characters in the prompt that somehow screws up the terminal (I have tried different terminals including xterm, rxvt, gnome-terminal, konsole, same result).
This must be a trivial problem, but I can't seem to solve it. I really want a boldface hostname because I've been using that for several years (different shell, different OS) and I use a lot of different machines and it's too easy to get the ssh sessions mixed up otherwise.
 
Old 08-17-2005, 05:03 PM   #2
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
Hehehe ... was working on this today myself..

You need to "escape" the entire command so that it isn't counted in the number of characters in a line..

A better explanation is at.. http://www.faqs.org/docs/Linux-HOWTO...NPRINTINGCHARS
 
Old 08-17-2005, 06:50 PM   #3
rpz
Member
 
Registered: Mar 2005
Posts: 126

Original Poster
Rep: Reputation: 15
Thank you for that link! Solved my problem right away. The correct prompt to use was
Code:
export PS1="\[\e[0;1m\]\h\[\e[0;0m\]:\u \A \w $ "
 
Old 08-18-2005, 03:54 AM   #4
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
Actually, you need some extra bits for it..
It needs an escaped e[0m at the end to reset any colors/bold/etc..
Try..
export PS1="\[\e[0;1m\]\h\[\e[0;0m\]:\u \A \w \$ \[\033[0m\]"

It is explained quite quickly earlier why to escape any "non-printing" characters and reset at the end of the line.

If you plan to use this in your .bashrc file, don't use the export command, just the PS1 definition..
I use
PS1='\[\033[1;37;40m\]\u\[\033[1;33m\]@\[\033[1;33m\]\h\[\033[1;37m\]\w\[\033[1;33m\]\$ \[\033[0m\]'
alias ls='ls --color=auto'
for an xterm with a white background..
 
Old 08-18-2005, 08:49 AM   #5
rpz
Member
 
Registered: Mar 2005
Posts: 126

Original Poster
Rep: Reputation: 15
Actually, that is not needed in my case, but thanks anyway.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I am an idiot!!!! jdmarti1 Linux - Software 5 09-23-2005 10:14 PM
Help me I'm an idiot. Nightwing Linux - Newbie 13 06-16-2004 12:09 PM
programming problem giving me headache rajatgarg Programming 2 05-12-2004 08:32 AM
Im an Idiot. Help! didlin Linux - Newbie 2 01-03-2004 01:15 PM
Red Hat 8.0 headache problem starting up...need to use fsck? OrganicX Linux - General 3 03-06-2003 05:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration