LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices

Reply
 
LinkBack Search this Thread
Old 05-09-2007, 01:43 PM   #1
Ordinary12
Member
 
Registered: Feb 2007
Posts: 140

Rep: Reputation: 15
Changing the prompt?


Hey Everyone:

I'm trying to get my prompt back to the way it was but I don't know how to do that. My prompt used to look something like this:

home/kendall ~

But now it looks like this:

[kendall@c-69-137-73-39 ~] $

How can I get it back to the way it was and can someone explain to me why it changed in the first place?
 
Old 05-09-2007, 02:31 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 64
Prompts are generally controlled by a shell variable such as PS1 (check the output of “echo $PS1” in bash). Generally, you change ~/.bashrc or similar. As for how it got that way, perhaps a rouge upgrade thought it might be better that way?
 
Old 05-09-2007, 03:23 PM   #3
Ordinary12
Member
 
Registered: Feb 2007
Posts: 140

Original Poster
Rep: Reputation: 15
I ran the command and this is what I got:

[\u@\h \W]\$

Can you tell me the command to change it back?
 
Old 05-09-2007, 03:45 PM   #4
0.o
Member
 
Registered: May 2004
Location: Raleigh, NC
Distribution: Debian, Solaris, HP-UX, AIX
Posts: 196

Rep: Reputation: 31
issue this command (if you are using bash)

export PS1="\[\033[1;34m\][\[\033[0;37m\]\t\[\033[1;34m\]] \[\033[1;34m\][\[\033[0;37m\]\u\[\033[1;34m\]@\[\033[0;37m\]\h \[\033[1;34m\](\[\033[0;37m\]\w\[\033[1;34m\])]\[\033[1;37m\]\$ \[\033[0;37m\]"

all one line.

The way i created this was using this little bit of code in my bashrc:

LBLUE="\[\033[1;34m\]"
LLBLUE="\[\033[1;33m\]"
LRED="\[\033[1;31m\]"
LPURPLE="\[\033[1;35m\]"
LGREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LGRAY="\[\033[0;37m\]"
export PS1="$LBLUE[$LGRAY\t$LBLUE] $LBLUE[$LGRAY\u$LBLUE@$LGRAY\h $LBLUE($LGRAY\w$LBLUE)]$WHITE\\$ $LGRAY"

If you assign the colors/styles to variables, it makes changing the prompt much, much easier.

Last edited by 0.o; 05-09-2007 at 03:46 PM.
 
Old 05-09-2007, 04:12 PM   #5
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 64
Quote:
Originally Posted by Ordinary12
Can you tell me the command to change it back?
You didn’t quite explain what it was previously…

If you want it to display “home/kendall ~” all the time, I suggest something like
Code:
PS1="home/kendall ~ "
I don’t understand the significance of “home/kendall” (is “home” your hostname and “kendall” your username?).

Here’s “home/kendall” followed by a space, followed by your the basename of your present working directory (with $HOME replaced by ~):
Code:
PS1="home/kendall \W "
Perhaps home/kendall is your present working directory minus the slash (this seems redundant to me):
Code:
PS1="`echo $PWD | cut -b2-` \W "
For more info, see this.

Last edited by osor; 05-09-2007 at 04:13 PM.
 
Old 05-09-2007, 05:08 PM   #6
Ordinary12
Member
 
Registered: Feb 2007
Posts: 140

Original Poster
Rep: Reputation: 15
This is just the prompt I had when I started out. I'm trying to follow along with this book I have but it's not as NOOB friendly as I need it to be. I'd really like to have a command line that adjusts to show me where I am in the directory.
 
Old 05-09-2007, 05:34 PM   #7
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 64
Here is a list of escape characters recognized by bash that can be used in your prompt. Notice \w and \W as the present working directory and the basename of the present working directory. (The difference between using $PWD and \w is that \w will replace $HOME with ~).
 
Old 05-10-2007, 07:57 AM   #8
0.o
Member
 
Registered: May 2004
Location: Raleigh, NC
Distribution: Debian, Solaris, HP-UX, AIX
Posts: 196

Rep: Reputation: 31
Quote:
Originally Posted by Ordinary12
This is just the prompt I had when I started out. I'm trying to follow along with this book I have but it's not as NOOB friendly as I need it to be. I'd really like to have a command line that adjusts to show me where I am in the directory.
If you use the command/prompt code that i showed you, it will display the hostname of the computer you are on, the user you are currently logged in as, the directory you are in, and show you the time.

Did you just decide to ignore the post?
 
Old 05-10-2007, 10:07 AM   #9
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 64
Quote:
Originally Posted by 0.o
Did you just decide to ignore the post?
I think he wanted his original prompt back.
 
Old 05-10-2007, 10:36 AM   #10
Ordinary12
Member
 
Registered: Feb 2007
Posts: 140

Original Poster
Rep: Reputation: 15
Hey Guys:

I really appreciate all the great information you gave me on here. I realize that it doesn't really matter what my prompt says as long as I know where I'm at and what my home is. Thanks. I'll play around with this for days. I am curious about something. How important is the Path command? Do you really use it that often? Oh....and can someone explain to me the difference is between \w and \W?

Last edited by Ordinary12; 05-10-2007 at 10:40 AM.
 
Old 05-10-2007, 08:22 PM   #11
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 64
Quote:
Originally Posted by Ordinary12
How important is the Path command? Do you really use it that often?
PATH, as far as I know, isn’t a command, it’s an environment variable (perhaps you’re thinking of a different path?). You (or your interpreter, rather) use it every time you execute a program without specifying it’s location. For example, whey you type “vi” at the terminal, your interpreter (probably bash) looks for an file with the execute bit set in the first directory in your PATH variable. If it can’t find such a file, it looks at the second directory, and so on. The field separator for PATH (as well as many other variables of that nature) is the colon (i.e., “:”).
Quote:
Originally Posted by Ordinary12
Oh....and can someone explain to me the difference is between \w and \W?
\w represents the full name of your present working directory. For example, if you were in “/usr/local/include”, then \w would expand to “/usr/local/include”. \W on the other hand, represents the “basename” of your present working directory (i.e., only what comes after the last slash). For example, if you were in “/usr/local/include”, then \W would expand to “include”.

P.S., In a script you can find the basename of a path by using the basename utility. E.g., “basename /usr/local/include” returns “include”.
 
Old 05-16-2007, 09:48 AM   #12
Ordinary12
Member
 
Registered: Feb 2007
Posts: 140

Original Poster
Rep: Reputation: 15
I changed my prompt to everything you guys showed me and it was all very cool but after I left it alone for two days I noticed that the prompt changed itself back to normal. Very strange.
 
Old 05-16-2007, 11:53 AM   #13
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 64
There must be some program interfering with your prompt (this is probably what changed it in the first place). Try to notice any patterns when this occurs (did you run a specific program prior to the change that you can remember?).
 
Old 05-23-2007, 08:35 PM   #14
kbneo
LQ Newbie
 
Registered: May 2007
Posts: 2

Rep: Reputation: 0
my prompt in terminal also changes to "bash-2.xxx #" today. I can't remember what I did yesterday to make it so. I type PS1="\w #" in terminal and it returns to what I want, but close and open terminal, it is back to bash prompt again.
i search around and finally add a file .bashrc with one line PS1="\w #" in the user directory and it works.
I am new to linux, so not sure if the above action will do anything to other parts of the system.
 
Old 05-23-2007, 10:05 PM   #15
kbneo
LQ Newbie
 
Registered: May 2007
Posts: 2

Rep: Reputation: 0
I think I may know what I did yesterday to change the prompt. I partitioned a fat32 to be /root using System -> Administration -> Logical Volumn Management. settings in /root are gone including prompt settings. can't auto detect usb as well. I guess have to re-install linux, again.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing the command Prompt Demon_Spawn Linux - Newbie 4 09-24-2006 09:09 PM
Changing the command prompt DJ KC Red Hat 3 10-10-2005 12:47 AM
Changing Bash Prompt socks Slackware 11 02-09-2005 06:32 PM
Changing the BASH Prompt Blade_Powers Linux - Newbie 4 03-28-2004 09:21 PM
Changing the Slackware Prompt wwwc21 Slackware 2 03-17-2004 10:51 AM


All times are GMT -5. The time now is 05:17 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration