exa/src/options/vars.rs
Benjamin Sago f6b7b7f298 Add exa_colors to make exa themable
This adds support for the EXA_COLORS environment variable, and defines a bunch of exa-specific two-letter codes that I pretty much made up arbitrarily that control parts of the interface.

Fixes #160, which I didn’t expect to actually fix this release cycle, but it unexpectedly became easy to do!
2017-08-26 23:17:07 +01:00

49 lines
1.5 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use std::ffi::OsString;
// General variables
/// Environment variable used to colour files, both by their filesystem type
/// (symlink, socket, directory) and their file name or extension (image,
/// video, archive);
pub static LS_COLORS: &str = "LS_COLORS";
/// Environment variable used to override the width of the terminal, in
/// characters.
pub static COLUMNS: &str = "COLUMNS";
// exa-specific variables
/// Environment variable used to colour exas interface when colours are
/// enabled. This includes all the colours that LS_COLORS would recognise,
/// overriding them if necessary. It can also contain exa-specific codes.
pub static EXA_COLORS: &str = "EXA_COLORS";
/// Environment variable used to switch on strict argument checking, such as
/// complaining if an argument was specified twice, or if two conflict.
/// This is meant to be so you dont accidentally introduce the wrong
/// behaviour in a script, rather than for general command-line use.
pub static EXA_STRICT: &str = "EXA_STRICT";
/// Environment variable used to limit the grid-details view
/// (`--grid --long`) so its only activated if theres at least the given
/// number of rows of output.
pub static EXA_GRID_ROWS: &str = "EXA_GRID_ROWS";
/// Mockable wrapper for `std::env::var_os`.
pub trait Vars {
fn get(&self, name: &'static str) -> Option<OsString>;
}
// Test impl that just returns the value it has.
#[cfg(test)]
impl Vars for Option<OsString> {
fn get(&self, _name: &'static str) -> Option<OsString> {
self.clone()
}
}