Dear all,
Since quite a while now, I get weird characters in my URXVT upon terminal resizing or tmux-attaching:
10;rgb:ffff/ffff/ffff11;rgb:0000/0000/0000
This problem has been discussed and addressed for Arch , but NixOS lacks the supercharged package that fixed it in Arch.
I am a little surprised that this bug did not draw more attention, given how popular tmux and urxvt are. Has anybody seen a workaround in NixOS?
tejing
July 13, 2025, 5:20am
2
I wonder if this is related⦠I recently noticed that a few programs, notably gh
, cause spurious weird characters to appear in my urxvt terminals. Iāll give that patch a try.
tejing
July 13, 2025, 6:01am
3
Unfortunately, while the patch does fix the problem for tmux, it doesnāt fix it for gh.
1 Like
TLATER
July 13, 2025, 7:51am
4
Well, on NixOS itās pretty trivial to patch stuff like this downstream:
{ pkgs, lib, ... }: {
environment.systemPackages = let
urxvt = pkgs.urxvt.overrideAttrs (old: {
patches = old.patches ++ [
(pkgs.fetchpatch {
name = "7-bit-queries.patch";
url = "https://aur.archlinux.org/cgit/aur.git/plain/7-bit-queries.patch?h=rxvt-unicode-truecolor-wide-glyphs";
extraPrefix = "";
hash = lib.fakeHash;
})
];
});
in [
urxvt
];
}
You can suggest this upstream too, if you read into the urxvt discussions and see why this isnāt just fixed there. Iām not a big fan of mindlessly applying patches.
1 Like
tejing
July 13, 2025, 9:25am
5
The tmux thing is already fixed upstream. They just havenāt released a new version yet.
Hereās the upstream change in patch form: urxvt-color-termination.patch Ā· GitHub
I tested that and it applies cleanly on rxvt-unicode 9.31 and fixes tmux. But it turns out my gh
problem was a whole different thing:
opened 12:48PM - 19 Apr 25 UTC
bug
needs-user-input
needs-triage
gh-pr
**Status update: https://github.com/cli/cli/issues/10830#issuecomment-2820571036⦠**
**This makes interactive `gh` commands essentially unusable in `urxvt` with version 2.70.0.**
**Environment:**
* `gh` version: `gh version 2.70.0 (2025-04-15)`
* Operating System: `Arch Linux`
* Terminal Emulator: `urxvt (rxvt-unicode)`
* `$TERM` environment variable value: Tested with various values (e.g., `rxvt-unicode-256color`, `rxvt-unicode`). The issue persists regardless of the specific `TERM` value set within `urxvt`.
* Shell: Reproducible in both `bash` and `zsh`.
**Steps to Reproduce:**
1. Open the `urxvt` terminal emulator.
2. Use either `bash` or `zsh` shell.
3. Run any `gh` command, for example, `gh version`.
**Observed Behavior:**
1. The command output, as well as the shell prompt area, gets interspersed with visible escape code sequences. These look like `^[]11;rgba:....^[` and `^[[...R`.
Example output when running `gh version`:
```plaintext
[user@host ~]$ gh version
^[]11;rgba:0000/0000/01ff/c000^[^[[4;1Rgh version 2.70.0 (2025-04-15)
https://github.com/cli/cli/releases/tag/v2.70.0
[user@host ~]$ [4;1R11;rgba:0000/0000/01ff/c000[4;1R
```
2. **Crucially, this issue also breaks interactive prompts, preventing commands like `gh pr create` from completing.** When an interactive prompt is displayed by `gh`, it contains unexpected characters (like `[48;1R` in the example below), and the command fails with an error related to unexpected escape sequences.
Example failure during `gh pr create`:
```plaintext
ā gh pr create
? Where should we push the 'ignore-tmp-dagster-home' branch? [48;1R [Use arrows to move, type to filter]
could not prompt: unexpected escape sequence from terminal: ['\x1b' ']']
Command exit code: 1
```
**Expected Behavior:**
The command output should be displayed cleanly without any visible escape code sequences mixed in.
```plaintext
[user@host ~]$ gh version
gh version 2.70.0 (2025-04-15)
https://github.com/cli/cli/releases/tag/v2.70.0
[user@host ~]$
```
**Additional Context:**
* This issue appears specifically in the `urxvt` terminal emulator. It was **not** reproducible in `gnome-terminal` on the same system using the same shells and `gh` version.
* This behavior started with `gh` version `2.70.0`. The previous version I used, `gh 2.69.0 (2025-03-19)`, worked correctly and did **not** produce these visible escape codes in the same `urxvt` terminal environment. This strongly suggests a change or potential regression introduced in v2.70.0 related to terminal interaction, specifically with `urxvt`.
* Changing the `TERM` environment variable value within `urxvt` did not resolve the issue.
Looks like anything using github.com/muesli/termenv is affected, including the formatter used by nixpkgs, treefmt .
2 Likes
tejing
July 13, 2025, 9:44am
6
@TLATER That snippet wonāt quite work, for a couple of reasons:
The package is actually pkgs.rxvt-unicode
.
Itās a wrapper around pkgs.rxvt-unicode-unwrapped
, which is what you need to patch.
The patch file isnāt quite made correctly to automatically apply inside stdenv.
Iāve actually tested this overlay structure:
pkgs: prevPkgs:
{
rxvt-unicode-unwrapped = prevPkgs.rxvt-unicode-unwrapped.overrideAttrs (prevAttrs: {
patches = (prevAttrs.patches or []) ++ [ ./urxvt-color-termination.patch ];
});
}
With ./urxvt-color-termination.patch
being a local copy of urxvt-color-termination.patch Ā· GitHub .
2 Likes
TLATER
July 13, 2025, 1:30pm
7
fetchpatch
should tape over that most of the time, would be curious what specifically doesnāt work here.
But yep, not tested at all, mainly trying to show how nixpkgsā override infrastructure works.
1 Like
tejing
July 13, 2025, 1:37pm
8
Itās a file path matching issue:
applying patch /nix/store/8gcgchzfnxyga0zbg8ybd72i49vi48jn-7-bit-queries.patch
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- a/a/src/command.C
|+++ b/b/src/command.C
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
13 out of 13 hunks ignored
can't find file to patch at input line 222
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- a/a/src/rxvt.h
|+++ b/b/src/rxvt.h
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
2 out of 2 hunks ignored
error: builder for '/nix/store/y3i1n5nkyw7hb2nq1lc9zgjm5qw6gsy6-rxvt-unicode-unwrapped-9.31.drv' failed with exit code 1;
stripLen = 1;
fixes it. (Or just leaving off extraPrefix
, apparently. Learning about a new piece of nixpkgs today )
2 Likes
Thanks @tejing and @tlater ! Great to hear this is being fixed upstream. I guess Iāll wait patiently then until it makes it into nixpkgs on its own.
Best,
Moritz
tejing
July 15, 2025, 4:58am
10
I made a PR to cherry-pick that patch in the nixpkgs version:
master
ā tejing1:urxvt-7-bit-queries
opened 04:50AM - 15 Jul 25 UTC
Cherry-picks an upstream change fixing a bug in urxvt's handling of certain OSC ⦠sequences, which causes tmux to leave garbage characters in the input buffer.
Context:
- https://discourse.nixos.org/t/https-bbs-archlinux-org-viewtopic-php-id-293022/66519
- https://github.com/tmux/tmux/issues/3470
- http://lists.schmorp.de/pipermail/rxvt-unicode/2023q1/002640.html
Note: There is a *separate* issue causing garbage characters in the input buffer in urxvt right now, which isn't urxvt's bug, but rather a [bug](https://github.com/muesli/termenv/issues/189) in a go library. This pr is unrelated to that issue. If you found this pr because you're having issues with `treefmt` or `gh`, go check that out.
## Things done
- Built on platform(s)
- [x] x86_64-linux
- [ ] aarch64-linux
- [ ] x86_64-darwin
- [ ] aarch64-darwin
- For non-Linux: Is sandboxing enabled in `nix.conf`? (See [Nix manual](https://nixos.org/manual/nix/stable/command-ref/conf-file.html))
- [ ] `sandbox = relaxed`
- [ ] `sandbox = true`
- [ ] Tested, as applicable:
- [NixOS test(s)](https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests) (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))
- and/or [package tests](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#package-tests)
- or, for functions and "core" functionality, tests in [lib/tests](https://github.com/NixOS/nixpkgs/blob/master/lib/tests) or [pkgs/test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/test)
- made sure NixOS tests are [linked](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#linking-nixos-module-tests-to-a-package) to the relevant packages
- [ ] Tested compilation of all packages that depend on this change using `nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"`. Note: all changes have to be committed, also see [nixpkgs-review usage](https://github.com/Mic92/nixpkgs-review#usage)
- [x] Tested basic functionality of all binary files (usually in `./result/bin/`)
- [Nixpkgs 25.11 Release Notes](https://github.com/NixOS/nixpkgs/blob/master/doc/release-notes/rl-2511.section.md) (or backporting [25.05](https://github.com/NixOS/nixpkgs/blob/master/doc/manual/release-notes/rl-2505.section.md) Nixpkgs Release notes)
- [ ] (Package updates) Added a release notes entry if the change is major or breaking
- [NixOS 25.11 Release Notes](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2511.section.md) (or backporting [25.05](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2505.section.md) NixOS Release notes)
- [ ] (Module updates) Added a release notes entry if the change is significant
- [ ] (Module addition) Added a release notes entry if adding a new NixOS module
- [x] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md), [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md), [maintainers/README.md](https://github.com/NixOS/nixpkgs/blob/master/maintainers/README.md) and other contributing documentation in corresponding paths.
---
Add a :+1: [reaction] to [pull requests you find important].
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
[pull requests you find important]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc
2 Likes