LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-02-2011, 03:56 PM   #1
EzioAuditore
Member
 
Registered: Mar 2011
Posts: 45

Rep: Reputation: 0
Help Customizing Terminal prompt


Hello,

I tried customizing the terminal header today, all good but one line appears after every command as shown in the screenshot..

How do I stop this from happening?

Below is the PS1 line from ~/.bashrc file:

Code:
PS1='Welcome back. How can I help you?\n${debian_chroot:+($debian_chroot)}\[\033[1;31m\]\u@\h\[\033[00m\]\[\033[1;31m:\]\[\033[1;31m\]\w\[\033[00m\]\[\033[1;31m$\] \[\033[1;34m\] '
Thanks!
Attached Thumbnails
Click image for larger version

Name:	capture.png
Views:	45
Size:	72.5 KB
ID:	6607  

Last edited by EzioAuditore; 04-03-2011 at 11:26 AM.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 04-02-2011, 04:08 PM   #2
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Rep: Reputation: 234Reputation: 234Reputation: 234
Change your PS1 to something like:

Code:
PS1="`hostname`:`pwd`# "
or:

Code:
PS1="\u@\h:\w\$ "
 
Old 04-02-2011, 04:18 PM   #3
EzioAuditore
Member
 
Registered: Mar 2011
Posts: 45

Original Poster
Rep: Reputation: 0
Won't these remove my customizations even? I just want that Welcome line to appear only once and not repeat after every command..
 
Old 04-03-2011, 11:21 AM   #4
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by EzioAuditore View Post
Won't these remove my customizations even? I just want that Welcome line to appear only once and not repeat after every command..
PS1 is not a "header" (such a thing doesn't even exist). It's the prompt.

.bashrc is executed every time you start an interactive prompt. Just add the commands to print your welcome message there.
 
Old 04-03-2011, 11:25 AM   #5
EzioAuditore
Member
 
Registered: Mar 2011
Posts: 45

Original Poster
Rep: Reputation: 0
Oh yeah yeah.. I meant the prompt... My bad..

Regarding the message, i added but it appears after every command.. I've posted my PS1 line in main post.. Can u post an edited version of it with the problem rectified?
 
Old 04-03-2011, 11:39 AM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by EzioAuditore View Post
Regarding the message, i added but it appears after every command.. I've posted my PS1 line in main post.. Can u post an edited version of it with the problem rectified?
???????????????????????

The prompt is supposed to appear after every command, that's why it's called the prompt!

If you want a message to appear when you open a terminal, you DO NOT do it by modifying PS1!
 
Old 04-03-2011, 12:05 PM   #7
EzioAuditore
Member
 
Registered: Mar 2011
Posts: 45

Original Poster
Rep: Reputation: 0
Ok Ok.. So what should be edited to achieve that?
 
Old 04-03-2011, 01:23 PM   #8
RockDoctor
Senior Member
 
Registered: Nov 2003
Location: Minnesota, US
Distribution: Fedora, Ubuntu, Manjaro
Posts: 1,791

Rep: Reputation: 427Reputation: 427Reputation: 427Reputation: 427Reputation: 427
If you're booting to the terminal, you might consider editing /etc/rc.local:
Code:
echo "Your prompt here"

Last edited by RockDoctor; 04-03-2011 at 01:25 PM.
 
Old 04-03-2011, 01:57 PM   #9
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by RockDoctor View Post
If you're booting to the terminal, you might consider editing /etc/rc.local:
Code:
echo "Your prompt here"
That's not a prompt!

Also, I'd put it in .bashrc, that way it will work everywhere. In .bashrc, just add code that will print the message. For example:

Code:
echo "You will see this every time you open a terminal"
And I hope you do understand what a prompt is, right?
 
2 members found this post helpful.
Old 04-03-2011, 02:26 PM   #10
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
There are several levels at which messages can be emitted.
  • An echo command in /etc/rc.local, or any of the startup scripts in /etc/init.d will be executed at boot time.
  • A message echoed from /etc/bashrc (variations per distro) will be emitted whenever an interactive bash shell is started by anyone on that host.
  • A message in your $HOME/.bashrc will be emitted whenever you launch a new shell.
  • A message in $PS1 will be emitted each time a new commandline can accept user input (which is why it is called a prompt, I suppose).
  • The Message Of The Day (/etc/motd) will be displayed after a login.

--- rod.

Last edited by theNbomr; 04-03-2011 at 02:29 PM.
 
Old 04-03-2011, 02:46 PM   #11
EzioAuditore
Member
 
Registered: Mar 2011
Posts: 45

Original Poster
Rep: Reputation: 0
Oh thanks for all your replies..
Its late night here... and also facing some boot problems..
I'll try these tomorrow and let you guys know..
 
Old 04-03-2011, 06:01 PM   #12
RockDoctor
Senior Member
 
Registered: Nov 2003
Location: Minnesota, US
Distribution: Fedora, Ubuntu, Manjaro
Posts: 1,791

Rep: Reputation: 427Reputation: 427Reputation: 427Reputation: 427Reputation: 427
Quote:
Originally Posted by MTK358 View Post
That's not a prompt!

Also, I'd put it in .bashrc, that way it will work everywhere. In .bashrc, just add code that will print the message. For example:

Code:
echo "You will see this every time you open a terminal"
And I hope you do understand what a prompt is, right?
It wasn't supposed to be a prompt (although that's what the original poster called it) - it's supposed to be a welcome message (I think) But, you're right, .bashrc would be a better place for it
 
Old 04-04-2011, 06:33 AM   #13
EzioAuditore
Member
 
Registered: Mar 2011
Posts: 45

Original Poster
Rep: Reputation: 0
Ok guys, that echo command did what I wanted. Now is there any way to have keywords like sudo, chmod etc to be in different color than the rest of the command?
 
Old 04-04-2011, 07:10 AM   #14
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by EzioAuditore View Post
Ok guys, that echo command did what I wanted. Now is there any way to have keywords like sudo, chmod etc to be in different color than the rest of the command?
No.
 
Old 04-04-2011, 01:07 PM   #15
EzioAuditore
Member
 
Registered: Mar 2011
Posts: 45

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by MTK358 View Post
No.
Okay! Thanks.
 
  


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
How to check missing header files included from another header file adisan82 Linux - Software 1 01-28-2011 03:57 AM
LXer: Customizing vim and coloring the terminal in OpenSolaris 2009.06 LXer Syndicated Linux News 0 07-12-2009 11:10 AM
customizing login on terminal balusss Linux - Software 1 04-22-2008 10:52 AM
Customizing Desktop thru Terminal burningsun1981 Linux - Newbie 8 07-03-2005 09:00 PM
c header files in linux in place of header files in windows? harun_acs Programming 1 03-17-2004 02:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:40 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