Repository: eza-community/eza (language: rust)

Issue:
feat:  Add environmental variable for git support. 
This is a very niche use-case, but I've currently got a project which causes perceptible lag whenever eza is run with the --git option. I've reverted to using direnv to disable the flag in a wrapper function to make it usable, but it would be nice if we can override flags using environmental variables.

# Issue example
## Time with `--git` 
<img width="437" alt="Screenshot 2023-10-07 at 20 44 57" src="https://github.com/eza-community/eza/assets/40488664/6076c0a6-7f2d-4552-91d2-eed235bf538f">


## Time without `--git`
<img width="397" alt="Screenshot 2023-10-07 at 20 48 52" src="https://github.com/eza-community/eza/assets/40488664/6c6c20fc-9ca8-44c0-8150-b4b841bb5a60">






Discussion / hints:
You can also use the `--no-git` option which overrides `--git`, so that it does not break your alias if you have one
(I think it is an interesting issue imo let's keep it open for now)
I am going to work on it I think

Fix patch:
diff --git a/man/eza.1.md b/man/eza.1.md
index 2e45b06c5..1819752b2 100644
--- a/man/eza.1.md
+++ b/man/eza.1.md
@@ -290,6 +290,10 @@ Specifies the colour scheme used to highlight files based on their name and kind
 
 For more information on the format of these environment variables, see the [eza_colors.5.md](eza_colors.5.md) manual page.
 
+## `EZA_OVERRIDE_GIT`
+
+Overrides any `--git` or `--git-repos` argument
+
 
 EXIT STATUSES
 =============
diff --git a/src/options/vars.rs b/src/options/vars.rs
index 44ecf0ac4..918974e18 100644
--- a/src/options/vars.rs
+++ b/src/options/vars.rs
@@ -52,6 +52,9 @@ pub static EZA_GRID_ROWS: &str = "EZA_GRID_ROWS";
 pub static EXA_ICON_SPACING: &str = "EXA_ICON_SPACING";
 pub static EZA_ICON_SPACING: &str = "EZA_ICON_SPACING";
 
+pub static EXA_OVERRIDE_GIT: &str = "EXA_OVERRIDE_GIT";
+pub static EZA_OVERRIDE_GIT: &str = "EZA_OVERRIDE_GIT";
+
 /// Mockable wrapper for `std::env::var_os`.
 pub trait Vars {
     fn get(&self, name: &'static str) -> Option<OsString>;
diff --git a/src/options/view.rs b/src/options/view.rs
index e2f434dec..40ba52779 100644
--- a/src/options/view.rs
+++ b/src/options/view.rs
@@ -231,7 +231,7 @@ impl TableOptions {
         let time_format = TimeFormat::deduce(matches, vars)?;
         let size_format = SizeFormat::deduce(matches)?;
         let user_format = UserFormat::deduce(matches)?;
-        let columns = Columns::deduce(matches)?;
+        let columns = Columns::deduce(matches, vars)?;
         Ok(Self {
             size_format,
             time_format,
@@ -242,14 +242,21 @@ impl TableOptions {
 }
 
 impl Columns {
-    fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
+    fn deduce<V: Vars>(matches: &MatchedFlags<'_>, vars: &V) -> Result<Self, OptionsError> {
+        use crate::options::vars;
         let time_types = TimeTypes::deduce(matches)?;
 
-        let git = matches.has(&flags::GIT)? && !matches.has(&flags::NO_GIT)?;
-        let subdir_git_repos = matches.has(&flags::GIT_REPOS)? && !matches.has(&flags::NO_GIT)?;
+        let no_git_env = vars
+            .get_with_fallback(vars::EXA_OVERRIDE_GIT, vars::EZA_OVERRIDE_GIT)
+            .is_some();
+
+        let git = matches.has(&flags::GIT)? && !matches.has(&flags::NO_GIT)? && !no_git_env;
+        let subdir_git_repos =
+            matches.has(&flags::GIT_REPOS)? && !matches.has(&flags::NO_GIT)? && !no_git_env;
         let subdir_git_repos_no_stat = !subdir_git_repos
             && matches.has(&flags::GIT_REPOS_NO_STAT)?
-            && !matches.has(&flags::NO_GIT)?;
+            && !matches.has(&flags::NO_GIT)?
+            && !no_git_env;
 
         let blocksize = matches.has(&flags::BLOCKSIZE)?;
         let group = matches.has(&flags::GROUP)?;


Test patch: