Link to home
Start Free TrialLog in
Avatar of bmclellan
bmclellan

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of hongjun
hongjun
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RobWMartin
RobWMartin

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

Avatar of bmclellan

ASKER

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

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