Open daveola opened 4 years ago
This is a mis-feature because the attribute is attached to the next character after the attribute specifier. The same happens for the regular prompt. Perhaps there should be special NUL attributed character that just sets the attribute and does not print the character, followed by a regular NUL terminator.
So by mis-feature you mean that this is a terminal issue and there's nothing that can be done about it? Is there not a zero-width character that I can place after?
There is a zero-width space in UTF-8, but it won't help, as the code doesn't understand it being zero-width, so the rprompt
is displayed one column too early. Thus it visually looks the same as if you used a normal space at its end.
Getting the zero-width space into rprompt
was an exercise in quoting (once again):
> perl -CO -e'print "set rprompt='"'"'%{\\033[1;31m%} rprompt%{\\033[0m%}\x{200b}'"'"'\n"' | vis
set rprompt='%{\134033[1;31m%} rprompt%{\134033[0m%}\M-b\M^@\M^K'
I saved that to a file to source it:
> perl -CO -e'print "set rprompt='"'"'%{\\033[1;31m%} rprompt%{\\033[0m%}\x{200b}'"'"'\n"' > rprompt.csh
> source rprompt.csh
By the way, vi(1) will not work correctly with that file, either, as it doesn't understand the zero-widthness of the zero-width space. So it e.g. $
places you one column too far (into "nothing"). Having the zero width space on the screen also confused screen(1) and/or mosh(1) so that some lines were stuck on the terminal display...
But taking your example:
set rprompt="%{\033[1;31m%} rprompt %{\033[0m%}"
You could just move the space preceding the colour code to be after it:
set rprompt="%{\033[1;31m%} rprompt%{\033[0m%} "
This would effectively give you the same appearance on screen, wouldn't it?
The tcsh(1) manual page does document the fact that a literal escape sequence cannot be the last sequence in a prompt.
Thanks for the ideas.
I tried the zero-width space and, at least on my terminal (xterm-256color) it still left my color stuck at red.
And yes, there was a space after "rprompt" in my example, but that was for readability. I want the "rprompt" to be fully right-justified, so having that space after the color is admittedly a fix for my example, but doesn't actually solve the problem.
On top of that I just realized that there seems to be an additional space added after rprompt regardless. I.e., if I have 80 columns, then the last character of even just a simple "set rprompt='hi'" will actually be at col 79, which doesn't make sense to me and is not consistent with the "left" prompt. So now I've got two spaces to deal with.. :(
I am experimenting with colors in tcsh prompts, and I use a prompt and rprompt.
I'm able to add colors to the prompt (and then turn off the color formatting fine), but when I add colors to the rprompt, I am unable to turn off the formatting.
As an example, for red:
So I tried these simple prompt settings:
And it turns everything red, including what I type and all my command results.
On the other hand, if you add any characters after the clear formatting codes, then the colors work as expected:
(Note the extra space)
This happens on multiple terminal types - is this a tcsh bug?