aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--doc/foot.1.scd11
-rw-r--r--doc/footclient.1.scd11
-rwxr-xr-xgenerate-version.sh1
-rw-r--r--slave.c3
5 files changed, 28 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 08d7d69f..01d664fc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -61,6 +61,8 @@
* “Report version” terminfo entries (`XR`/`xr`).
* “Report DA2” terminfo entries (`RV`/`rv`).
* `XF` terminfo capability (focus in/out events available).
+* `$TERM_PROGRAM` and `$TERM_PROGRAM_VERSION` environment variables
+ set in the slave process.
[1136]: https://codeberg.org/dnkl/foot/issues/1136
[1225]: https://codeberg.org/dnkl/foot/issues/1225
diff --git a/doc/foot.1.scd b/doc/foot.1.scd
index 6f63d4c8..51c53130 100644
--- a/doc/foot.1.scd
+++ b/doc/foot.1.scd
@@ -546,6 +546,17 @@ In all other cases, the exit code is that of the client application
This variable is set to *truecolor*, to indicate to client
applications that 24-bit RGB colors are supported.
+*TERM_PROGRAM*
+ Always set to *foot*. This can be used by client applications to
+ check which terminal is in use, but with the caveat that it may
+ have been inherited from a parent process in other terminals that
+ aren't known to set the variable.
+
+*TERM_PROGRAM_VERSION*
+ Set to the foot version string, in the format _major_*.*_minor_*.*_patch_
+ or _major_*.*_minor_*.*_patch_*-*_revision_*-\g*_commit_ for inter-release
+ builds. The same caveat as for *TERM_PROGRAM* applies.
+
In addition to the variables listed above, custom environment
variables may be defined in *foot.ini*(5).
diff --git a/doc/footclient.1.scd b/doc/footclient.1.scd
index 63235134..189d9e3c 100644
--- a/doc/footclient.1.scd
+++ b/doc/footclient.1.scd
@@ -158,6 +158,17 @@ terminfo entries manually, by copying *foot* and *foot-direct* to
This variable is set to *truecolor*, to indicate to client
applications that 24-bit RGB colors are supported.
+*TERM_PROGRAM*
+ Always set to *foot*. This can be used by client applications to
+ check which terminal is in use, but with the caveat that it may
+ have been inherited from a parent process in other terminals that
+ aren't known to set the variable.
+
+*TERM_PROGRAM_VERSION*
+ Set to the foot version string, in the format _major_*.*_minor_*.*_patch_
+ or _major_*.*_minor_*.*_patch_*-*_revision_*-\g*_commit_ for inter-release
+ builds. The same caveat as for *TERM_PROGRAM* applies.
+
In addition to the variables listed above, custom environment
variables may be defined in *foot.ini*(5).
diff --git a/generate-version.sh b/generate-version.sh
index a030d512..3772008b 100755
--- a/generate-version.sh
+++ b/generate-version.sh
@@ -41,6 +41,7 @@ patch=$(echo "${new_version}" | sed -r 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\3/')
extra=$(echo "${new_version}" | sed -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)(-([0-9]+-g[a-z0-9]+) .*)?.*/\5/')
new_version="#define FOOT_VERSION \"${new_version}\"
+#define FOOT_VERSION_SHORT \"${git_version:-${default_version}}\"
#define FOOT_MAJOR ${major}
#define FOOT_MINOR ${minor}
#define FOOT_PATCH ${patch}
diff --git a/slave.c b/slave.c
index d4861ad0..2f23e996 100644
--- a/slave.c
+++ b/slave.c
@@ -21,6 +21,7 @@
#include "macros.h"
#include "terminal.h"
#include "tokenize.h"
+#include "version.h"
#include "xmalloc.h"
extern char **environ;
@@ -351,6 +352,8 @@ slave_spawn(int ptmx, int argc, const char *cwd, char *const *argv,
}
setenv("TERM", term_env, 1);
+ setenv("TERM_PROGRAM", "foot", 1);
+ setenv("TERM_PROGRAM_VERSION", FOOT_VERSION_SHORT, 1);
setenv("COLORTERM", "truecolor", 1);
setenv("PWD", cwd, 1);