Changing Unix Prompt

I was looking through a Unix book and it gave a sample for changing the unix command prompt:

   PS1='$PWD ^J\$ '

This should get a prompt like
     /home/user
     $

unfortunately I get the prompt
     /home/user ^J$

Can anyone tell me how to get this prompt on two lines!

Thanks
bmclellanAsked:
Who is Participating?
 
hongjunConnect With a Mentor Commented:
The below command should give you what you want.

PS1='$PWD\n\$'
0
 
RobWMartinCommented:
Well, let's see.  You're obviously not using csh.  It's either sh, ksh, bash, or some other sh variant.  Most modern shells based on sh allow you to use backslash escapes.  Thus, try

PS1='$PWD \n\$ '

Hope this helps

0
 
bmclellanAuthor Commented:
Thanks, since I got the comment from two people, I will assume that my shell is not taking the \ as an escape. The solution above resulted in the 'n' being printed, and no second line.

Thanks anyways
Barry
0
 
bganoushCommented:

What you neglected to explain that when you see "^J" or "^" followed by anything, this means that you should replace that character with the escape code for that character.

In most VT emulators, just type CTRL-V followed by CTRL-J instead of the "^J" sequence in the original command.

-- Bubba
0
All Courses

From novice to tech pro — start learning today.