Przeglądaj źródła

Merge pull request #598 from RyanBreaker/icons_env

feat: create EZA_ICONS_AUTO environment variable
MartinFillon 2 lat temu
rodzic
commit
46a0ee0365
3 zmienionych plików z 12 dodań i 1 usunięć
  1. 6 0
      man/eza.1.md
  2. 2 1
      src/options/file_name.rs
  3. 4 0
      src/options/vars.rs

+ 6 - 0
man/eza.1.md

@@ -302,6 +302,12 @@ For more information on the format of these environment variables, see the [eza_
 
 Overrides any `--git` or `--git-repos` argument
 
+## `EZA_ICONS_AUTO`
+
+If set, automates the same behavior as using `--icons` or `--icons=auto`. Useful for if you always want to have icons enabled.
+
+Any explicit use of the `--icons=WHEN` flag overrides this behavior. 
+
 
 EXIT STATUSES
 =============

+ 2 - 1
src/options/file_name.rs

@@ -45,8 +45,9 @@ impl ShowIcons {
             Automatic,
         }
 
+        let force_icons = vars.get(vars::EZA_ICONS_AUTO).is_some();
         let mode_opt = matches.get(&flags::ICONS)?;
-        if !matches.has(&flags::ICONS)? && mode_opt.is_none() {
+        if !force_icons && !matches.has(&flags::ICONS)? && mode_opt.is_none() {
             return Ok(Self::Never);
         }
 

+ 4 - 0
src/options/vars.rs

@@ -55,6 +55,10 @@ 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";
 
+/// Environment variable used to automate the same behavior as `--icons=auto` if set.
+/// Any explicit use of `--icons=WHEN` overrides this behavior.
+pub static EZA_ICONS_AUTO: &str = "EZA_ICONS_AUTO";
+
 /// Mockable wrapper for `std::env::var_os`.
 pub trait Vars {
     fn get(&self, name: &'static str) -> Option<OsString>;