1834711 Members
2474 Online
110069 Solutions
New Discussion

Prompt like msdos

 
SOLVED
Go to solution
irbaboon
Advisor

Prompt like msdos

Hi, it??s a dumb question......

How to make a prompt like msdos??? ex: hostname:\dir
10 REPLIES 10
Marco Santerre
Honored Contributor
Solution

Re: Prompt like msdos

in your .profile (or in /etc/profile if you wanna make it system-wide), you just have to export the PS1 value.

export PS1=`hostname`":"'$PWD'" >"

That should look good
Cooperation is doing with a smile what you have to do anyhow.
Pete Randall
Outstanding Contributor

Re: Prompt like msdos

In you .profile:

export PS1="`hostname` `pwd`# "



Pete

Pete
John Poff
Honored Contributor

Re: Prompt like msdos

Hi,

Not a dumb question at all. We setup the prompt for root for all our boxes to display hostname:dir.

Try putting this in your .profile:

PS1=`hostname`:'$PWD > '


JP

P.S. At first I thought you were going to ask to change the prompt to C:> which would be funny!
Volker Borowski
Honored Contributor

Re: Prompt like msdos

Hi,

I would vote much AGAINST having ">" in a prompt !

To be honest, I destroyed a rather important file once, by using cut&paste in a hurry and caused a wrong redirection.

"#" indeed is a very friendly character as a last one of a prompt, because if clipped and pasted by accident, it tells the shell to ignore the rest as a comment.

Yeah, life can be a hard thing, I will not tell here which one I zeroed out :-)
Volker
Ross Zubritski
Trusted Contributor

Re: Prompt like msdos

oooooooooooooo, lemme guess???

/stand/vmunix

LOL

;)
John Poff
Honored Contributor

Re: Prompt like msdos

Volker,

Ouch! We use the '#' prompt for root and '>' for other users, so at least we won't run into your problem as root.

JP
John Meissner
Esteemed Contributor

Re: Prompt like msdos

we use "#" for root
and "$" for everyone else

here is another suggestion:

Set your PS1 so that it's like this:
username:hostname:dir$
for regular users and:
root:hostname:dir#
for root
All paths lead to destiny
Donny Jekels
Respected Contributor

Re: Prompt like msdos

not dumb question,

however it is dumb using ">" in your prompt as an end.

try cut and paste and accidently picking up the > sign.

# > /etc/passwd

hmmm.... not a great idea

also in > indicates a continuation prompt.

such as $for x in `ls`
you get a > back

my 2 cents - and horrible experience - yes laugh!!!
"Vision, is the art of seeing the invisible"
Bill Hassell
Honored Contributor

Re: Prompt like msdos

Just a note on the use of the grave accent in POSIX shell scripts: The reverse apostrophe or grave accent is considered deprecated (in Unix-speak: obsolete). The problem is that the actual character is very easy to misinterpret with a plain apostrophe or single quote mark. In this web page, the two characters are:

'`

But the appearance of the character is 100% dependent on the character set used on the current display device. To make things really nasty, MS Word (by default) will change single quotes into open-close apostrophes thinking that this is plain text and not a scripting language. And imagine what it looks like on a fax (noise or a real tic mark?) More than a few sysadmins could not get a script to work because the grave accent is easily mistaken.

To use command substitution, recommended usage is $( command ). Not only is this much more readable but it it easily nested. So for the prompt:

PS1=$(hostname):'$PWD # '

Note that Unix convention for many years is to use # for a root prompt and $ for an ordinary user prompt, both are safe characters for an accidental copy-paste.


Bill Hassell, sysadmin
harry d brown jr
Honored Contributor

Re: Prompt like msdos


Better yet, make your PC's prompt look like unix:

http://www.suse.com/index_us.html

http://www.redhat.com

http://www.mandrakelinux.com/en/

(sorry if I missed a few - which I know I did - stressed for time)

It worked for me :-)

live free or die
harry
Live Free or Die