Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Use TERM_PROGRAM for determining WezTerm terminal #185

Merged
merged 2 commits into from Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,11 @@ To publish a new release run `scripts/release` from the project directory.

## [Unreleased]

### Changed
- Use `TERM_PROGRAM` for determining WezTerm terminal (see [GH-185]).

[GH-185]: https://github.com/lunaryorn/mdcat/pull/185

## [0.23.0] – 2021-07-04

### Added
Expand Down
18 changes: 10 additions & 8 deletions mdcat.1.adoc
Expand Up @@ -33,7 +33,7 @@ The environment variables `$MDCAT_PAGER` and `$PAGER` control the pager used.

=== Image support

In iTerm2, Kitty and Terminology mdcat prints inline images.
In iTerm2, Kitty, Terminology and WezTerm mdcat prints inline images.
mdcat supports most standard pixel formats by default.

mdcat silently ignores images larger than 100 MiB.
Expand All @@ -42,7 +42,7 @@ mdcat silently ignores images larger than 100 MiB.

In Terminology mdcat also renders SVG images, using the built-in support of Terminology.

In iTerm2 and Kitty mdcat requires `rsvg-convert` to render SVG images to pixel graphics before displaying them;
In iTerm2, Kitty and WezTerm mdcat requires `rsvg-convert` to render SVG images to pixel graphics before displaying them;
if `rsvg-convert` is not found in `$PATH` mdcat does not render SVG images in these terminals.

=== HTTP/HTTPS support
Expand All @@ -57,7 +57,7 @@ In this case remote images render as hyperlinks.
--paginate::
Paginate the output of mdcat with a pager like less.
+
**Note:** When paginating mdcat only uses basic ANSI formatting (no images, no hyperlinks) because oager programs normally do not support any sophisticated ANSI formatting features.
**Note:** When paginating mdcat only uses basic ANSI formatting (no images, no hyperlinks) because pager programs normally do not support any sophisticated ANSI formatting features.
+
This is the default when run as `mdless`.

Expand Down Expand Up @@ -102,13 +102,14 @@ If run as `mdless` or if `--paginate` is given and the pager fails to start mdca
== Environment

TERM::
If this variable is `xterm-kitty` assume that the terminal is Kitty.
If this variable is `xterm-kitty`, assume that the terminal is Kitty.

TERM_PROGRAM::
If this variable is `iTerm.app` mdcat assumes that the terminal is iTerm2.
If this variable is `iTerm.app`, mdcat assumes that the terminal is iTerm2.
If this variable is `WezTerm`, mdcat assumes that the terminal is WezTerm.

TERMINOLOGY::
If this variable is `1` mdcat assumes that the terminal is Terminology.
If this variable is `1`, mdcat assumes that the terminal is Terminology.

VTE_VERSION::
The version of a VTE-based terminal (such as Gnome Terminal).
Expand All @@ -135,7 +136,7 @@ The pager program must support basic ANSI formatting sequences, like e.g. `less
The value of this variable is subject to shell-like word-splitting.
It is **not** subject to any kind of expansion or substitution (e.g. parameter expansion, process subsitution, etc.).
+
If set to an empty value mdcat completely disables pagination.
If set to an empty value, mdcat completely disables pagination.

PAGER::
The pager program to use if `$MDCAT_PAGER` is unset.
Expand Down Expand Up @@ -173,7 +174,7 @@ mdcat parses HTML blocks and inline tags but does not apply special rendering; i

=== Terminal support

Unless `--no-colour` is given mdcat translates CommonMark text into ANSI formatted text, with standard SGR formatting codes.
Unless `--no-colour` is given, mdcat translates CommonMark text into ANSI formatted text, with standard SGR formatting codes.
It uses bold (SGR 1), italic (SGR 3) and strikethrough (SGR 9) formatting, and the standard 4-bit color sequences.
It does not use 8-bit or 24-bit color sequences, though this may change in future releases.

Expand All @@ -184,6 +185,7 @@ https://iterm2.com/documentation-escape-codes.html[Marks].
* https://github.com/kovidgoyal/kitty[Kitty]: OSC 8 hyperlinks and https://sw.kovidgoyal.net/kitty/graphics-protocol.html[Kitty Graphics].
* http://terminolo.gy[Terminology]: OSC 8 hyperlinks and Terminology inline images.
* https://wiki.gnome.org/Apps/Terminal/VTE[VTE 3 based] (0.50 or newer): OSC 8 hyperlinks.
* https://wezfurlong.org/wezterm/[WezTerm]: OSC 8 hyperlinks and iTerm2 inline images.

== Bugs

Expand Down
2 changes: 1 addition & 1 deletion src/terminal.rs
Expand Up @@ -82,7 +82,7 @@ fn get_vte_version() -> Option<(u8, u8)> {

/// Checks if the current terminal is WezTerm.
fn is_wezterm() -> bool {
std::env::var("TERM").map_or(false, |value| value == "wezterm")
std::env::var("TERM_PROGRAM").map_or(false, |value| value == "WezTerm")
}

impl TerminalCapabilities {
Expand Down