LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Suse/Novell (http://www.linuxquestions.org/questions/suse-novell-60/)
-   -   question about bash look and feel (http://www.linuxquestions.org/questions/suse-novell-60/question-about-bash-look-and-feel-271067/)

Hockeyfan 12-28-2004 04:39 AM

question about bash look and feel
 
I have suse 9.2 pro. My problem is with the bash shell. I have been using Redhat/Fedora for a few years. Over that time I have gotten used to thethe following look in the terminal

[paul@hockeyfan Documents]$

In my suse distribution the command prompt looks more like the windows command prompt. Is there any way I can make the comand prompt look like the above format rather then the windows format?

According to yast I am running a bash shell, /bin/bash to be exact


Hockeyfan

amfoster 12-28-2004 05:51 AM

Your personal enviroment in SuSE is controlled by either the .profile or the .bashrc file in your home directory.

simply change the prompt there.

example in .profile

PS1="$USER@$HOSTNAME"

I use this prompt:

PS1="
`whoami`@`hostname`
cmd-> "

Then in the same file export the variable
export PS1

=================

Right now, your prompt is set for every user in the
/etc/profile or possibly the /etc/bash.bashrc file

You can change it there as well.

The .profile is read only once when you first log in. The .bashrc is read everytime you open a new shell (bash)

eco2geek 12-28-2004 06:30 AM

Look at the bash prompt HOWTO and the "Prompting" section of the bash man page for all sorts of options.

For what you posted, try typing this at a bash prompt (this is just temporary):

PS1="[\u@\h \W]$ "

If you like it, put the following at the end of your ~/.bashrc:

# Fedora-like bash prompt
PS1="[\u@\h \W]$ "

Then become root, and put the following at the end of your ~/.bashrc (you may need to create it):

# Fedora-like bash prompt
PS1="[\u@\h \W]# "

If you want to go back to the default, just comment those lines out of ~/.bashrc or delete them (for your normal user and for root).

(Now why the "/$" escape sequence isn't working, I don't know, but it didn't work for me.)

amfoster 12-28-2004 07:07 AM

(Now why the "/$" escape sequence isn't working, I don't know, but it didn't work for me.)


I didn't see that in the code above.... But anyway, it would be a \ (backslash)

Example:

PS1="`whoami`@`hostname`:\$PWD"

Which would constantly update when you changed directories. Without the bachslash \$PWD The prompt would always show the same directory.

eco2geek 12-28-2004 04:29 PM

Oops, that's what I meant, "\$" not "/$", sorry. It's supposed to display a "#" when you're root (UID=0) and a "$" for any other user.


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