Koozali.org: home of the SME Server

shell prompt

Jay

shell prompt
« on: January 29, 2002, 06:12:24 PM »
Hi,

Is there a way of displaying the current path in the shell prompt a-la (dare I say it) windowz prompt $p$g ?

Cheers

robert

Re: shell prompt
« Reply #1 on: January 29, 2002, 06:28:36 PM »
pwd

(print working directory)

robert

Re: shell prompt
« Reply #2 on: January 29, 2002, 07:28:04 PM »
Sorry, I think I misread your question. This is probably an environment variable that you can set, but I'm not at my Linux machine right now, so I don't know which one (maybe $PROMPT). Sorry if this isn't very helpful.

robert

Re: shell prompt
« Reply #3 on: January 29, 2002, 09:49:02 PM »
Jay wrote:
>
> Hi,
>
> Is there a way of displaying the current path in the shell
> prompt a-la (dare I say it) windowz prompt $p$g ?
>
I don't use Windows, so I don't know what that does, but I think this is what you're looking for:

export PS1='[\u@\h \w]\$'

To reset to original setting:

export PS1='[\u@\h \W]\$'

To check current setting:

echo $PS1

Hope this is more helpful ;-)

Jay

Re: shell prompt
« Reply #4 on: January 30, 2002, 02:23:24 PM »
Top man!! thanks for that.

Is there a way to make the change permenant ?

robert

Re: shell prompt
« Reply #5 on: January 30, 2002, 03:13:43 PM »
Jay wrote:
>
> Is there a way to make the change permenant ?

Yes, put the line in /root/.bashrc right after the alias bits. By the way, the default prompt has a space after the # sign. If you want that back, you should include that space in the quotes, so it would be:
export PS1='[\u@\h \w]\$ '
That's even neater. You can also include other stuff in the prompt, such as time and or date, but then you don't have any space left to type your commands. I find it less annoying to occasionally type 'date' when I want to know the time and 'pwd' when I want to know the full path to where I am. To find out what the other options for the prompt are, you should either install man and read the PROMPTING part from the bash man page ('man bash') or read this man page online through www.linuxdoc.org.

Jay

Re: shell prompt
« Reply #6 on: January 30, 2002, 04:24:29 PM »
Thanks again....and I get the hint :)

Cheers

robert

Re: shell prompt
« Reply #7 on: January 30, 2002, 05:04:26 PM »
Jay wrote:
>
> Thanks again....and I get the hint :)
>
No hint intended. Though it's always a good idea to visit www.linuxdoc.org when you have a linux-related question.
One more thing: I thought you always needed to specify 'export' when setting an environment variable, but apparently this is not so. So, you can just put a line in /root/.bashrc that says:
PS1='your favorite prompt '
(It's getting simpler all the time ;-)
Ciao