Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: prompt quoting question

On Aug 27, 12:49am, Russell Hoover wrote:
} It seems to me the problem is in correctly quoting the 's/\/dev\/tty//' :
} the single quotes (within backtics within single quotes) won't cut it.

Backticks within single quotes are not recognized as quotes.  Quotation
forms normally do not nest.  There are two exceptions, and both apply
only when the outermost quotes are double quotes:

1. Inside "$(...)", all forms of quoting may appear within the parens.
2. Inside "${...}", balanced double quotes may appear within the braces.

The possible solutions are:

a. Use double quotes (or none at all) around the argument to sed.
    RPS1=$'...`/usr/bin/tty | sed -e s@/dev/tty@@`...'
b. End the $'...' expression before you begin some other quoting.
    RPS1=$'...''`/usr/bin/tty | sed -e s@/dev/tty@@`'$'...'

Neither helps in cases where the nesting quotes can't be eliminated by
other trickery; (b) might be simpler in some circumstances, but not in
this case.

For this particular question, though, I think the best solution is:

c. Use the %l or %y prompt escape instead of that sed command.

    RPS1=$'%{\e[1;34m%} %l %{\e[1;32m%}%D{%A  %Y/%m/%d  %T} %{\e[m%}'

Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   

Messages sorted by: Reverse Date, Date, Thread, Author