Closed scuzzilla closed 1 year ago
I'd like to reproduce the problem on my end. I've set up OpenBSD in a virtual machine, and I'm using tmux
, but I don't see the prompt garbled after using man
. A few questions:
xterm
because it was preinstalled, but you may be using something more modern.man
using? Are MANPAGER
or PAGER
set?less
, do you have a LESS
environment variable, and what is its value?Thanks!
Hi @agkozak,
To address your queries:
Terminal: I'm currently logged in to a virtual terminal directly, without any terminal emulation, so I'm not using X or any graphical environment.
Pager Settings: I have the following settings in my .kshrc
for the pager:
export PAGER=$(which most)
So, I'm using most
as my pager.
LESS Environment Variable: Yes, I have the LESS
environment variable set. Here's its value from my .kshrc
:
export LESS='-iMRS -x2'
I hope this provides clarity for you to reproduce the issue. Let me know if you need more details or any further information.
Best, Salvatore.
Yes, I can reproduce the problem exactly as you see it, and your fix works.
I've done a lot of testing with this prompt, and I've had to change the non-printing character at least once, that I can remember, so that it would satisfy all setups. I could ultimately only get \016
to work on all of them -- except, it turns out, your case, with tmux
involved. Your solution may be the right one. Give me a little while to do some research.
And thanks, as always, for your contributions.
Yes, the problem can occur on NetBSD even without tmux
. I'll keep testing.
@scuzzilla -
Your patch works as intended as long as you're using a default OpenBSD or NetBSD console.
Unfortunately, if I ssh
into an OpenBSD instance using a common terminal like mintty
or Windows Terminal, \021
causes problems with wrapping or causes non-printing characters to be displayed. So I don't think we can see it as a blanket solution for OpenBSD and NetBSD.
What I might consider doing is allowing the user to set POLYGLOT_NP
themselves, e.g., make line 700 of the master
branch
: ${POLYGLOT_NP:-"\016"}
so that the user can put
POLYGLOT_NP="\021"
into their dotfiles -- if that is the non-printing character that addresses their use case.
I don't think there's any ideal solution to this problem; pdksh
's support for color is imperfect, and I actually removed support for color at one point in the past for exactly this reason. But I think we're approaching the closest thing to a solution.
Hi @agkozak,
Regarding Microsoft terminal applications: I found (and tested) that the issue can be circumvented by setting the correct terminal emulation. For instance, in the "PowerShell Console", setting
$env:TERM = "vt100"
does the trick.
I've also tested with Cygwin (mintty) and PuTTY, and the behavior is consistent and without issues.
As for the 'Windows Terminal', it wasn't available in my basic Windows 10 installation. I'm not sure if it's bundled in the default installation. However, given the solutions and workarounds for other Microsoft terminal applications, I'm hopeful.
I believe that with my contribution, along with some concise documentation addressing Microsoft terminal scenarios, we should be able to handle most use cases effectively.
Looking forward to further directions or suggestions.
Best, Salvatore.
These are all great observations. Let me think about this for a day or two.
Hi @agkozak,
I hope you're doing well. I was just touching base to see if you've had a chance to consider the observations I shared a few days ago.
Regards, Salvatore.
Yes, I think I know what I'd like to do. I'll write it up for you in a few hours. Thanks for your patience.
I propose doing the following:
# pdksh uses an arbitrary non-printing character to delimit color escape
# sequences in the prompt. In practice, however, it is impossible to find
# one single non-printing character that will work with all operating systems
# and terminals. The Polyglot Prompt defaults to \021 for OpenBSD/NetBSD
# and \016 for everything else. If you want to specify your own non-printing
# character, do so thus:
#
# POLYGLOT_NP="\016" # Set this variable to whatever value you like
#
# Or set POLYGLOT_PDKSH_COLORS=0 to disable color entirely in pdksh.
case ${POLYGLOT_UNAME} in
NetBSD*|OpenBSD*) POLYGLOT_NP=${POLYGLOT_NP:-"\021"} ;;
*) POLYGLOT_NP=${POLYGLOT_NP:-"\016"} ;;
esac
if _polyglot_is_pdksh &&
_polyglot_has_colors &&
[ ${POLYGLOT_PDKSH_COLORS:-1} -ne 0 ]; then
PS1=$(print "$POLYGLOT_NP\r")
case $POLYGLOT_UNAME in
NetBSD*|OpenBSD*) PS1=$PS1$(print "$POLYGLOT_NP") ;;
esac
PS1=$PS1$(print "\033[31;1m$POLYGLOT_NP")
etc.
That way we
POLYGLOT_NP
themselves;POLYGLOT_PDKSH_COLORS=0
)What do you think? If you agree, make the necessary changes, and I'll add a section to the documentation explaining how it all works.
Hi @agkozak,
Thank you for reviewing my comments. The proposed changes are completely reasonable, and I've already incorporated them into the original PR.
Please let me know if there's anything else you'd like to add or modify before merging.
Best, Salvatore.
Fantastic. Thanks for all your help.
Summary
When running the latest version of Polyglot on OpenBSD with ksh and tmux, I encountered 'prompt rendering' issues. These issues, for instance, manifest after exiting
man
pages. It's notable that the problem arises only in conjunction withtmux
.Setup
Steps to Reproduce
(tmux is running) Open a
man
page:Exit the
man
page.Observe the erroneous prompt rendering: