Gerard Lally dixit:
>I understand that print -f is not a feature of mksh. Is there another
>way of achieving the desired result?
You can assign the desired string to a variable, then use typeset
to set alignment on it. For example:
PS1=$'${|typeset -R$COLUMNS REPLY="[$USER@$HOSTNAME:$PWD]";}\n'
Dissolved:
PS1='${|typeset -R$COLUMNS REPLY="[$USER@$HOSTNAME:$PWD]";}'$'\n'
Part 2 is just a newline. Part 1 is assigned literally:
${|typeset -R$COLUMNS REPLY="[$USER@$HOSTNAME:$PWD]";}
This is then evaluated every time PS1 is shown.
${| … ;} is a function block that evaluates to $REPLY. That is,
${| REPLY=x ;} is the same as $(echo x), except with less overhead.
typeset -R$COLUMNS makes a right-aligned space-padded variable.
The rest is just its content.
HTH & HAND,
//mirabilos
--
"How can you ban language, words? How're words offensive? And why should I
have to tolerate YOUR interpretation? I'm the one using the word. ASK me how
I'm using it, don't TELL me. And if you don't like the way I'm using it, so
what? It's my right. It's my freedom of expression. Without that, we're
nothing but slaves." -- Johnny Rotten