Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is the a way to specify a multi line prompt in Korn shell?

I am planning to swhitch from bash to ksh. In bash I have a very simplistic prompt, but it is 2 line prompt. I hate when input position changes depending on directory depth. My PS1 in bash is:

PS1='$(echo $?): \w\n>> '

Which results in prompt like:

0: /var/log
>> _
share|improve this question
add comment

1 Answer

Just put an embedded newline inside the string:

PS1='$(echo $?): $PWD
>> '
share|improve this answer
    
Such a trivial thing! I tried putting newline char and it did not work. Did not think about explicitly putting newline. –  Andreas Nov 7 '11 at 12:38
    
May I suggest you change the >> to something else? '> or >> in a prompt may lead to nasty results if you accidentally cut&paste your screen contents. Maybe » or with an UTF-8 charset is also a nice prompt and has no special meaning for a shell. –  ktf Nov 7 '11 at 15:51
    
$'\n' will embed a newline too. –  amphetamachine Nov 8 '11 at 0:06
    
@amphetamachine, not in my Ksh. Where you tried that? –  manatwork Nov 8 '11 at 8:37
    
I think $'string' is bash only which wouldn't help here. The embedded newline approach is probably the easiest way to do it. –  jw013 Nov 8 '11 at 20:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.