FedoraThis forum is for the discussion of the Fedora Project.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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?
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.
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 ~).
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.
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.
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”.
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.
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?).
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.