-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
z4h breaks konsole in conjunction with theme.sh
#203
Comments
Thanks for filing the bug and providing a lot of information. I appreciate it. This bug unfortunately falls under the category of bugs that I won't be looking into: #35 (comment) |
Thank you for coming back to me. I respect your decision and I can completely unterstand it 👍 However if I could ask one thing of you, if you had to give an educated guess, how tmux breaks the console here, I would appreciate your input. Invoking simply If I would manage to reproduce this with standalone Thank you in advance, your input would help a lot! PS: |
My educated guess is that z4h doesn't break konsole, theme.sh does. It probably looks at You can check whether this is the case by starting a regular This also suggests a workaround when using z4h: run I should repeat that this is just a guess. It's possible that there is no bug in
Most of the time other stuff breaks tmux and not the other way around. A lot of software around TTYs relies on heuristics and those heuristics often don't work when one is using tmux. Most of those heuristics are plain bugs that can be fixed but it's an uphill battle.
It's the other way around. z4h doesn't need session management. It uses tmux only for rendering. More specifically, z4h needs to be able to save the current screen, do some drawing over it, and then restore it. In the ideal world, when switching to alternate screen there would be an option that says whether the screen should be emptied or not. In the world we live in this is unspecified and terminals can do whatever. |
Well thanks a lot for your insights, and taking the time to explain the context of what we are dealing with.
I would like to try that but on running |
It's just |
Now you hit the sport there somewhat.
Nice one, yes! This seems to be a valid workaround. No garbled characters in konsole anymore.
So I guess that is what I should suggest to the |
Great! Closing then.
Sure, why not. I've thrown together a script that allows you to detect whether the TTY is tmux. Here it is: #!/usr/bin/env zsh
#
# Usage: is-tmux-tty
#
# Returns 0 if stdin is a tmux TTY. Non-zero otherwise.
emulate -L zsh -o err_exit -o no_unset
[[ -t 0 ]]
zmodload zsh/terminfo
[[ $terminfo[xt] == yes || $terminfo[clear] == $'\e['* ]]
exec >&0
local resp
IFS= read -srt 5 -d c $'resp?\e[>c'
while [[ $resp != *$'\e[>'* ]]; do
IFS= read -srt 5 -d c 'resp[-1]?'
done
[[ $resp == *$'\e[>84'(|\;*) ]] Put it in
The script is written in zsh because that's what I use. It can be ported to other languages although it might require some work. |
Hi, author of theme.sh here.
Indeed.
I would argue that the bug is in z4h.
This is an unreasonable expectation and a large number of programs will not do this in practice (including tmux). It is a perfectly reasonable thing to assume that tmux is running if |
What happens if I run
It's the other way around. Within z4h it's like in the scenario I described above: the TTY is tmux (and it will identify itself as such if you ask it) but |
Here's another case where the TTY is tmux but Start You cannot assume that if |
No, but then neither will a lot of things. For this (and other reasons) the script is intended to be run locally.
Then this is still pathological behaviour. z4h should not touch
Running
Yes, you can (unless something breaks it). tmux itself does this. Are you suggesting tmux is implemented incorrectly? The whole point of the |
z4h is touching
tmux doesn't assume that the TTY is not tmux if
I'm suggesting that |
Then why is this an issue? I am responding to your claims that a program cannot rely on
You are cherry picking parts of the code. I already linked to a part of it which explcitly checks for the presence of
It already does (see above). Even if it didn't, there are many other programs and hand written scripts which rely on this behaviour. To ignore them breaks your code in a large number of instances. |
A program cannot assume that the TTY is not tmux merely because
By third party you mean
This is false. I've mentioned two additional cases where the TTY is tmux and yet Here's a third: run
z4h has builtin integration with tmux. This is irrelevant to this issue.
There are references to the environment variable named
You must be mistaken. |
Since it appears we are having a dialog of the deaf, this will be my final response.
It depends on what you mean by 'cannot'. Under most circumstances this is a reasonable assumption. The fact that an ssh session is run in a remote environment has nothing to do with whether or not
This is self evident, but running in a modified environment breaks a lot of things (including parts of tmux), so it is irrelevant. Environment variables exist for a reason and are used for this sort of detection in the real world. If z4h breaks this in the local context, then it is broken.
I mean z4h. ssh and sudo do things which explicitly change the user's envrionment, z4h is an off the shelf set of defaults which should not cause other pieces of software to break in the local context.
This is disingenuous. You can't launch X programs in an ssh session either, this is par for the course since it is understood that the user is running in the remote machine's environment. If the user installs a piece of software on their local machine it should not modify local environment variables which belong to other programs period.
See above. This will also break a lot of other software. Running something in a foreign environment has implications which should be understood by the user, it does not follow that it is ok to mangle the user's local environment.
I am mainly responding to your implicit claim that it is ok for z4h to modify (or unset) TMUX if it chooses. I won't pretend to be intimately familiar with your code, but it does seem that you set TMUX in some places.
Not in every instance. The fact that tmux inspects TMUX at all suggests that it is not ok for other programs to touch it. If theme.sh breaks in the same circumstances as the tmux client, then that is fine.
It also uses it to determine whether or not tmux is runnning (as referenced in the code I linked to).
Yes, it does more sophisticated checks in other parts of the code. I have never claimed that theme.sh is equally robust, however tmux does rely on the existence of TMUX in some instances, which should be a good enough reason not to mangle it.
This would not be an issue if z4h did not break the user's local environment.
theme.sh avoids this for performance reasons. Relying on |
Acknowledged. |
Hi,
I am using zsh4humans with konsole and I am also using a simple script called
theme.sh
to manage my terminal colors (it allows setting uniform colors in all terminals).Now sadly this, in conjunction with zsh4human breaks my konsole session:
After some trial and error I was able to nail it down further: setting
zstyle ':z4h:' start-tmux 'no'
solves the issue.So it has something to do, with how zsh4human utilizes
tmux
. I was not able to reproduce this by just runningtmux
in konsole.Steps to reproduce
theme.sh
from https://github.com/lemnos/theme.sh (it is a simple script and does not require a lot of effort)theme.sh gruvbox
Other terminals I have tested are not affected.
The text was updated successfully, but these errors were encountered: