From 8b1945d8fa8a318bab258e1a25153dd073e046a0 Mon Sep 17 00:00:00 2001 From: Thomas Koutcher Date: Fri, 21 May 2021 18:31:00 +0200 Subject: [PATCH] Add TIG_EDITOR environment variable to configure editor (#1098) Closes #889 --- doc/tig.1.adoc | 5 +++++ doc/tigrc.5.adoc | 3 ++- src/display.c | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/tig.1.adoc b/doc/tig.1.adoc index 23ae19d83..950da2eb6 100644 --- a/doc/tig.1.adoc +++ b/doc/tig.1.adoc @@ -235,6 +235,11 @@ TIG_NO_DISPLAY:: Open Tig without rendering anything to the terminal. This force Ncurses to write to /dev/null. The main use is for automated testing of Tig. +TIG_EDITOR:: + The editor command to use when visiting files. This environment + variable overrides $GIT_EDITOR, $EDITOR and $VISUAL, so it allows + to use a different editor from the one Git uses. + FILES ----- '$XDG_CONFIG_HOME/tig/config':: diff --git a/doc/tigrc.5.adoc b/doc/tigrc.5.adoc index 523eef2c0..8bb5eb776 100644 --- a/doc/tigrc.5.adoc +++ b/doc/tigrc.5.adoc @@ -67,7 +67,8 @@ the Git configuration: 'core.editor':: - The editor command. Can be overridden by setting GIT_EDITOR. + The editor command. Can be overridden by setting TIG_EDITOR or + GIT_EDITOR. 'core.worktree':: diff --git a/src/display.c b/src/display.c index e42b28d40..b33aeb82b 100644 --- a/src/display.c +++ b/src/display.c @@ -132,7 +132,9 @@ open_editor(const char *file, unsigned int lineno) const char *editor; int argc = 0; - editor = getenv("GIT_EDITOR"); + editor = getenv("TIG_EDITOR"); + if (!editor) + editor = getenv("GIT_EDITOR"); if (!editor && *opt_editor) editor = opt_editor; if (!editor)