Re: PS1 prompt problem

2009-10-16 Thread Chet Ramey
Nils wrote: > > Yes, that was the problem, I did not take into account that bash > expands $PS1 twice. No, it doesn't. It performs additional expansions besides those specified by Posix. > Is this double expansion even POSIX compliant? Yes. -- ``The lyf so short, the craft so long to lerne.'

Re: PS1 prompt problem

2009-10-16 Thread Nils
On 16 Okt., 21:18, Chet Ramey wrote: > Sort of.  I think you're overlooking the various expansion (and backslash > escaping) that's taking place with your prompt. > > Since you set the value of PS1 to literal string containing a command > substitution, the value will be expanded twice before being

Re: PS1 prompt problem

2009-10-16 Thread Chet Ramey
Nils wrote: > I'm using bash 3.2 and I'd like to set my prompt to the following > (inspired by the Opensolaris prompt for ksh93): > > PS1='$( > spwd="${PWD/#${HOME}/~}" > [[ ${#spwd} -gt 10 ]] && spwd="...${spwd: -10}" > printf "%...@%s:%s%s " "\u" "\h" "${spwd}" "\$" > termtitle="

Re: PS1 prompt problem

2009-10-16 Thread Andreas Schwab
Nils writes: > Following a suggestion in comp.unix.shell putting the above code > contained in $() inside a separate function f and setting PS1='$( f )' > displays the $spwd correctly in both the prompt and xterm title, but > bash escapes like "\u", "\h" etc are not expanded any more You could p

PS1 prompt problem

2009-10-16 Thread Nils
I'm using bash 3.2 and I'd like to set my prompt to the following (inspired by the Opensolaris prompt for ksh93): PS1='$( spwd="${PWD/#${HOME}/~}" [[ ${#spwd} -gt 10 ]] && spwd="...${spwd: -10}" printf "%...@%s:%s%s " "\u" "\h" "${spwd}" "\$" termtitle="\...@\h:${spwd}"