contour-terminal / contour

Modern C++ Terminal Emulator
http://contour-terminal.org/
Apache License 2.0
2.47k stars 107 forks source link

Expose current profile's name through env var or `contour` front-end VT call #1637

Closed whisperity closed 1 month ago

whisperity commented 1 month ago

In order to allow shell scripts to rely on setting the environment up for a particular colour scheme and behaviour, the current (or startup) profile's name should be queryable either through an environment variable, or via a VT sequence and a front-end hook similar to contour capture.

Contour Terminal version

0.5.1.7247

Installer source

GitHub: release page

Operating System

macOS San Sequioya 15.1

Architecture

ARM64

Other Software

No response

Steps to reproduce

Add an environment variable into the Contour configuration, such as

profiles:
    master:
        environment:
            FOO: "Bar"
default_profile: "master"

Spawn a shell, echo $FOO, and nothing comes out.

Expected Behavior

The environment variables get defined. This used to work, at least on Linux some time ago.

Actual Behavior

Nothing comes out, the variable is left undefined.

Additional notes

$ contour debug "config"
[2024-10-16 15:10:27.823766] [config] Loading default profile: master
[2024-10-16 15:10:27.823772] [config] loading profile master
[2024-10-16 15:10:27.823809] [config] Defaulting TERM to contour.

While a lot of configuration options are mentioned in the log file as "loading entry: ...", environment is not.

Yaraslaut commented 1 month ago

We dropped this functionality at some point, i suppose it is better to let shell define environment variables and not add this into config directly

whisperity commented 1 month ago

Oh, apologies, I missed the memo about this. 😉 I don't really have a hard need for this feature as long as we could at least query, from a shell script, which Contour profile was started (the name should be enough!) so I could create a script which branches on whether I'm using profile master, bright, or ssh.

Yaraslaut commented 1 month ago

Yes, this we can do, expose environmental variable CONTOUR_PROFILE or something like this