Przeglądaj źródła

Merge branch 'main' into pr-370

Christina Sørensen 2 lat temu
rodzic
commit
2243f82fb7

+ 36 - 0
.github/workflows/stale.yml

@@ -0,0 +1,36 @@
+# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
+#
+# You can adjust the behavior by modifying this file.
+# For more information, see:
+# https://github.com/actions/stale
+name: Mark stale issues and pull requests
+
+on:
+  schedule:
+  - cron: '42 3 * * *'
+
+jobs:
+  stale:
+
+    runs-on: ubuntu-latest
+    permissions:
+      issues: write
+      pull-requests: write
+
+    steps:
+    - uses: actions/stale@v5
+      with:
+        repo-token: ${{ secrets.GITHUB_TOKEN }}
+        
+        days-before-pr-stale: 30
+        days-before-pr-close: 14
+        stale-pr-message: 'This pull request is stale because it has been open for 30 days with no activity.'
+        close-pr-message: 'This pull request was closed because it has been inactive for 14 days since being marked as stale.'
+        stale-pr-label: 'stale › pr'
+        
+        days-before-issue-stale: 30
+        days-before-issue-close: 14
+        stale-issue-message: 'This issue is stale because it has been open for 30 days with no activity.'
+        close-issue-message: 'This issue was closed because it has been inactive for 14 days since being marked as stale.'
+        stale-issue-label: 'stale › issue'
+

+ 3 - 3
.github/workflows/unit-tests.yml

@@ -2,14 +2,14 @@ name: Unit tests
 
 on:
   push:
-    branches: [ master ]
+    branches: [ main ]
     paths:
       - '.github/workflows/*'
       - 'src/**'
       - 'Cargo.*'
       - build.rs
   pull_request:
-    branches: [ master ]
+    branches: [ main ]
     paths:
       - '.github/workflows/*'
       - 'src/**'
@@ -28,7 +28,7 @@ jobs:
     strategy:
       matrix:
         os: [ubuntu-latest, macos-latest]
-        rust: [1.63.0, stable, beta, nightly]
+        rust: [1.71.0, stable, beta, nightly]
 
     steps:
       - name: Checkout repository

+ 136 - 0
CODE_OF_CONDUCT.md

@@ -0,0 +1,136 @@
+
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+We as members, contributors, and leaders pledge to make participation in our
+community a harassment-free experience for everyone, regardless of age, body
+size, visible or invisible disability, ethnicity, sex characteristics, gender
+identity and expression, level of experience, education, socio-economic status,
+nationality, personal appearance, race, caste, color, religion, or sexual
+identity and orientation.
+
+We pledge to act and interact in ways that contribute to an open, welcoming,
+diverse, inclusive, and healthy community.
+
+## Our Standards
+
+Examples of behavior that contributes to a positive environment for our
+community include:
+
+* Demonstrating empathy and kindness toward other people
+* Being respectful of differing opinions, viewpoints, and experiences
+* Giving and gracefully accepting constructive feedback
+* Accepting responsibility and apologizing to those affected by our mistakes,
+  and learning from the experience
+* Focusing on what is best not just for us as individuals, but for the overall
+  community
+
+Examples of unacceptable behavior include:
+
+* The use of sexualized language or imagery, and sexual attention or advances of
+  any kind
+* Trolling, insulting or derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or email address,
+  without their explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+  professional setting
+
+## Enforcement Responsibilities
+
+Community leaders are responsible for clarifying and enforcing our standards of
+acceptable behavior and will take appropriate and fair corrective action in
+response to any behavior that they deem inappropriate, threatening, offensive,
+or harmful.
+
+Community leaders have the right and responsibility to remove, edit, or reject
+comments, commits, code, wiki edits, issues, and other contributions that are
+not aligned to this Code of Conduct, and will communicate reasons for moderation
+decisions when appropriate.
+
+## Scope
+
+This Code of Conduct applies within all community spaces, and also applies when
+an individual is officially representing the community in public spaces.
+Examples of representing our community include using an official e-mail address,
+posting via an official social media account, or acting as an appointed
+representative at an online or offline event.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported to the community leaders responsible for enforcement at:
+
+matrix: @cafkafk:nixos.dev
+
+All complaints will be reviewed and investigated promptly and fairly.
+
+All community leaders are obligated to respect the privacy and security of the
+reporter of any incident.
+
+## Enforcement Guidelines
+
+Community leaders will follow these Community Impact Guidelines in determining
+the consequences for any action they deem in violation of this Code of Conduct:
+
+### 1. Correction
+
+**Community Impact**: Use of inappropriate language or other behavior deemed
+unprofessional or unwelcome in the community.
+
+**Consequence**: A private, written warning from community leaders, providing
+clarity around the nature of the violation and an explanation of why the
+behavior was inappropriate. A public apology may be requested.
+
+### 2. Warning
+
+**Community Impact**: A violation through a single incident or series of
+actions.
+
+**Consequence**: A warning with consequences for continued behavior. No
+interaction with the people involved, including unsolicited interaction with
+those enforcing the Code of Conduct, for a specified period of time. This
+includes avoiding interactions in community spaces as well as external channels
+like social media. Violating these terms may lead to a temporary or permanent
+ban.
+
+### 3. Temporary Ban
+
+**Community Impact**: A serious violation of community standards, including
+sustained inappropriate behavior.
+
+**Consequence**: A temporary ban from any sort of interaction or public
+communication with the community for a specified period of time. No public or
+private interaction with the people involved, including unsolicited interaction
+with those enforcing the Code of Conduct, is allowed during this period.
+Violating these terms may lead to a permanent ban.
+
+### 4. Permanent Ban
+
+**Community Impact**: Demonstrating a pattern of violation of community
+standards, including sustained inappropriate behavior, harassment of an
+individual, or aggression toward or disparagement of classes of individuals.
+
+**Consequence**: A permanent ban from any sort of public interaction within the
+community.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage],
+version 2.1, available at
+[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
+
+Community Impact Guidelines were inspired by
+[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
+
+For answers to common questions about this code of conduct, see the FAQ at
+[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
+[https://www.contributor-covenant.org/translations][translations].
+
+[homepage]: https://www.contributor-covenant.org
+[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
+[Mozilla CoC]: https://github.com/mozilla/diversity
+[FAQ]: https://www.contributor-covenant.org/faq
+[translations]: https://www.contributor-covenant.org/translations
+

+ 9 - 2
Cargo.lock

@@ -13,9 +13,9 @@ dependencies = [
 
 [[package]]
 name = "autocfg"
-version = "1.0.1"
+version = "1.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
+checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
 
 [[package]]
 name = "bitflags"
@@ -75,6 +75,7 @@ dependencies = [
  "scoped_threadpool",
  "term_grid",
  "terminal_size",
+ "timeago",
  "unicode-width",
  "users",
  "zoneinfo_compiled",
@@ -297,6 +298,12 @@ dependencies = [
  "winapi",
 ]
 
+[[package]]
+name = "timeago"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ec32dde57efb15c035ac074118d7f32820451395f28cb0524a01d4e94983b26"
+
 [[package]]
 name = "tinyvec"
 version = "1.2.0"

+ 5 - 4
Cargo.toml

@@ -1,15 +1,15 @@
 [package]
 name = "eza"
 description = "A modern replacement for ls"
-authors = ["Benjamin Sago <ogham@bsago.me>", "Christina Sørensen <christina@cafkafk.com>"]
+authors = ["Christina Sørensen <christina@cafkafk.com>"]
 categories = ["command-line-utilities"]
 edition = "2021"
-rust-version = "1.63.0"
+rust-version = "1.71.0"
 exclude = ["/devtools/*", "/Justfile", "/Vagrantfile", "/screenshots.png"]
 readme = "README.md"
 homepage = "https://github.com/cafkafk/eza"
 license = "MIT"
-repository = "https://github.com/cafkafk/ez"
+repository = "https://github.com/cafkafk/eza"
 version = "0.10.1"
 
 
@@ -30,6 +30,7 @@ number_prefix = "0.4"
 scoped_threadpool = "0.1"
 term_grid = "0.1"
 terminal_size = "0.1.16"
+timeago = { version = "0.3.1", default-features = false }
 unicode-width = "0.1"
 zoneinfo_compiled = "0.5.1"
 
@@ -71,7 +72,7 @@ opt-level = "s"
 license-file = [ "LICENCE", "4" ]
 depends = "$auto"
 extended-description = """
-eza is a replacement for ls written in Rust.
+eza is a modern, maintained replacement for ls 
 """
 section = "utils"
 priority = "optional"

+ 44 - 15
README.md

@@ -2,27 +2,43 @@
 
 # eza
 
-eza is a modern replacement for _ls_.
+eza is a modern, maintained replacement for ls, built on [exa](https://github.com/ogham/exa).
 
 **README Sections:** [Options](#options) — [Installation](#installation) — [Development](#development)
 
-[![Unit tests](https://github.com/ogham/exa/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/ogham/exa/actions/workflows/unit-tests.yml)
-[![Say thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/ogham%40bsago.me)
+[![Built with Nix](https://img.shields.io/badge/Built_With-Nix-5277C3.svg?logo=nixos&labelColor=73C3D5)](https://nixos.org)
+[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](code_of_conduct.md)
+
+[![Unit tests](https://github.com/cafkafk/eza/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/cafkafk/eza/actions/workflows/unit-tests.yml)
+![Crates.io](https://img.shields.io/crates/v/eza?link=https%3A%2F%2Fcrates.io%2Fcrates%2Feza)
+![Crates.io](https://img.shields.io/crates/l/eza?link=https%3A%2F%2Fgithub.com%2Fcafkafk%2Feza%2Fblob%2Fmain%2FLICENCE)
+
 </div>
 
-![Screenshots of exa](screenshots.png)
+![Screenshots of eza](screenshots.png)
 
 ---
 
-**eza** is a modern replacement for the venerable file-listing command-line program `ls` that ships with Unix and Linux operating systems, giving it more features and better defaults.
+**eza** is a modern, maintained replacement for the venerable file-listing command-line program `ls` that ships with Unix and Linux operating systems, giving it more features and better defaults.
 It uses colours to distinguish file types and metadata.
 It knows about symlinks, extended attributes, and Git.
 And it’s **small**, **fast**, and just **one single binary**.
 
 By deliberately making some decisions differently, eza attempts to be a more featureful, more user-friendly version of `ls`.
-For more information, see [exa’s website](https://the.exa.website/).
 
 
+---
+
+**eza** features not in exa (non-exhaustive):
+
+ -   Fixes [“The Grid Bug”](https://github.com/cafkafk/eza/issues/66#issuecomment-1656758327) introduced in exa 2021.
+ -   Hyperlink support.
+ -   Selinux context output.
+ -   Git repo status output.
+ -   Human readable relative dates.
+ -   Several security fixes (see [dependabot](https://github.com/cafkafk/eza/security/dependabot?q=is%3Aclosed))
+ -   Many smaller bug fixes/changes!
+
 ---
 
 <a id="try-it">
@@ -45,20 +61,33 @@ If you want to pass arguments this way, use e.g. `nix run github:cafkafk/eza --
 
 eza is available for macOS and Linux.
 
-### Cargo
+### Cargo (crates.io)
+
+![Crates.io](https://img.shields.io/crates/v/eza?link=https%3A%2F%2Fcrates.io%2Fcrates%2Feza)
 
 If you already have a Rust environment set up, you can use the `cargo install` command:
 
     cargo install eza
 
-Cargo will build the `eza` binary and place it in `$HOME/.cargo`.
+Cargo will build the `eza` binary and place it in `$HOME/.local/share/cargo/bin/eza`.
 
-To build without Git support, run `cargo install --no-default-features eza` is also available, if the requisite dependencies are not installed.
+### Cargo (git)
 
+If you already have a Rust environment set up, you can use the `cargo install` command in your local clone of the repo:
+
+    git clone https://github.com/cafkafk/eza.git
+    cd eza
+    cargo install --path .
+
+Cargo will build the `eza` binary and place it in `$HOME/.cargo`.
 
 ---
+Click sections to expand.
 
 <a id="options">
+<details>
+    <summary> Command-line options </summary>
+
 <h1>Command-line options</h1>
 </a>
 
@@ -124,19 +153,20 @@ Some of the options accept parameters:
 - Valid **--color** options are **always**, **automatic**, and **never**.
 - Valid sort fields are **accessed**, **changed**, **created**, **extension**, **Extension**, **inode**, **modified**, **name**, **Name**, **size**, **type**, and **none**. Fields starting with a capital letter sort uppercase before lowercase. The modified field has the aliases **date**, **time**, and **newest**, while its reverse has the aliases **age** and **oldest**.
 - Valid time fields are **modified**, **changed**, **accessed**, and **created**.
-- Valid time styles are **default**, **iso**, **long-iso**, and **full-iso**.
+- Valid time styles are **default**, **iso**, **long-iso**, **full-iso**, and **relative**.
 
-
----
+</details>
 
 <a id="development">
+<details>
+    <summary> Development </summary>
 <h1>Development
 
 <a href="https://blog.rust-lang.org/2022/08/11/Rust-1.63.0.html">
     <img src="https://img.shields.io/badge/rustc-1.63.0+-lightgray.svg" alt="Rust 1.63.0+" />
 </a>
 
-<a href="https://github.com/ogham/exa/blob/master/LICENCE">
+<a href="https://github.com/cafkafk/eza/blob/master/LICENCE">
     <img src="https://img.shields.io/badge/licence-MIT-green" alt="MIT Licence" />
 </a>
 </h1></a>
@@ -168,8 +198,6 @@ If you’re unable to compile libgit2, you can opt out of Git support by running
 - If you intend to compile for musl, you will need to use the flag `vendored-openssl` if you want to get the Git feature working.
 The full command is `cargo build --release --target=x86_64-unknown-linux-musl --features vendored-openssl,git`.
 
-For more information, see the [Building from Source page](https://the.exa.website/install/source).
-
 ### Developing on Nix (experimental) ❄️
 
 If you have a working Nix installation with flake support, you can use nix to manage your dev environment.
@@ -219,3 +247,4 @@ Of course, the drawback of having a standard development environment is that you
 For this reason, Vagrant isn’t a *necessary* development step — it’s there if you’d like to use it, but eza still gets used and tested on other platforms.
 It can still be built and compiled on any target triple that it supports, VM or no VM, with `cargo build` and `cargo test`.
 
+</details>

+ 1 - 1
completions/bash/eza

@@ -29,7 +29,7 @@ _eza()
             ;;
 
         --time-style)
-            COMPREPLY=( $( compgen -W 'default iso long-iso full-iso --' -- "$cur" ) )
+            COMPREPLY=( $( compgen -W 'default iso long-iso full-iso relative --' -- "$cur" ) )
             return
             ;;
     esac

+ 1 - 0
completions/fish/eza.fish

@@ -80,6 +80,7 @@ complete -c eza        -l 'time-style'    -d "How to format timestamps" -x -a "
     iso\t'Display brief ISO timestamps'
     long-iso\t'Display longer ISO timestaps, up to the minute'
     full-iso\t'Display full ISO timestamps, up to the nanosecond'
+    relative\t'Display relative timestamps'
 "
 complete -c eza        -l 'no-permissions'    -d "Suppress the permissions field"
 complete -c eza -s 'o' -l 'octal-permissions' -d "List each file's permission in octal format"

+ 1 - 1
completions/zsh/_eza

@@ -44,7 +44,7 @@ __eza() {
         {-n,--numeric}"[List numeric user and group IDs.]" \
         {-S,--blocks}"[List each file's number of filesystem blocks]" \
         {-t,--time}="[Which time field to show]:(time field):(accessed changed created modified)" \
-        --time-style="[How to format timestamps]:(time style):(default iso long-iso full-iso)" \
+        --time-style="[How to format timestamps]:(time style):(default iso long-iso full-iso relative)" \
         --no-permissions"[Suppress the permissions field]" \
         {-o, --octal-permissions}"[List each file's permission in octal format]" \
         --no-filesize"[Suppress the filesize field]" \

+ 15 - 40
flake.nix

@@ -1,77 +1,60 @@
 {
   inputs = {
-
     flake-utils.url = "github:numtide/flake-utils";
-
     naersk.url = "github:nix-community/naersk";
-
     nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
-
     treefmt-nix.url = "github:numtide/treefmt-nix";
-
     rust-overlay.url = "github:oxalica/rust-overlay";
-
   };
 
   outputs = {
-      self
-    , flake-utils
-    , naersk
-    , nixpkgs
-    , treefmt-nix
-    , rust-overlay
+    self,
+    flake-utils,
+    naersk,
+    nixpkgs,
+    treefmt-nix,
+    rust-overlay,
   }:
     flake-utils.lib.eachDefaultSystem (
-
       system: let
-
         overlays = [(import rust-overlay)];
 
         pkgs = (import nixpkgs) {
-
           inherit system overlays;
-
         };
 
         toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
 
         naersk' = pkgs.callPackage naersk {
-
           cargo = toolchain;
-
           rustc = toolchain;
-
+          clippy = toolchain;
         };
 
         treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
-
-      in {
-
+      in rec {
         # For `nix fmt`
-
         formatter = treefmtEval.config.build.wrapper;
 
-
-        # packages.default = naersk'.buildPackage {
-
-        #   src = ./.;
-
-        # };
         packages = {
           # For `nix build` & `nix run`:
           default = naersk'.buildPackage {
             src = ./.;
+            doCheck = true; # run `cargo test` on build
           };
+
           # Run `nix build .#check` to check code
           check = naersk'.buildPackage {
             src = ./.;
             mode = "check";
           };
+
           # Run `nix build .#test` to run tests
           test = naersk'.buildPackage {
             src = ./.;
             mode = "test";
           };
+
           # Run `nix build .#clippy` to lint code
           clippy = naersk'.buildPackage {
             src = ./.;
@@ -80,25 +63,17 @@
         };
 
         # For `nix develop`:
-
         devShells.default = pkgs.mkShell {
-
           nativeBuildInputs = with pkgs; [toolchain];
-
         };
 
         # for `nix flake check`
-
         checks = {
-
           formatting = treefmtEval.config.build.check self;
-
+          build = packages.check;
+          test = packages.test;
+          lint = packages.clippy;
         };
-
       }
-
     );
-
 }
-
-

+ 1 - 1
man/eza.1.md

@@ -160,7 +160,7 @@ These options are available when running with `--long` (`-l`):
 `--time-style=STYLE`
 : How to format timestamps.
 
-: Valid timestamp styles are ‘`default`’, ‘`iso`’, ‘`long-iso`’, and ‘`full-iso`’.
+: Valid timestamp styles are ‘`default`’, ‘`iso`’, ‘`long-iso`’, ‘`full-iso`’, and ‘`relative`’.
 
 `-u`, `--accessed`
 : Use the accessed timestamp field.

+ 1 - 1
rust-toolchain.toml

@@ -1,4 +1,4 @@
 [toolchain]
 channel = "nightly"
-components = [ "rustfmt", "rustc", "rust-src", "rust-analyzer", "cargo" ]
+components = [ "rustfmt", "rustc", "rust-src", "rust-analyzer", "cargo", "clippy" ]
 profile = "minimal"

BIN
screenshots.png


+ 1 - 1
src/info/filetype.rs

@@ -28,7 +28,7 @@ impl FileExtensions {
             "build.gradle", "pom.xml", "Rakefile", "package.json", "Gruntfile.js",
             "Gruntfile.coffee", "BUILD", "BUILD.bazel", "WORKSPACE", "build.xml", "Podfile",
             "webpack.config.js", "meson.build", "composer.json", "RoboFile.php", "PKGBUILD",
-            "Justfile", "Procfile", "Dockerfile", "Containerfile", "Vagrantfile", "Brewfile",
+            "Justfile", "Procfile", "Dockerfile", "Earthfile", "Containerfile", "Vagrantfile", "Brewfile",
             "Gemfile", "Pipfile", "build.sbt", "mix.exs", "bsconfig.json", "tsconfig.json",
         ])
     }

+ 40 - 30
src/options/filter.rs

@@ -150,27 +150,32 @@ impl DotFilter {
 
     /// Determines the dot filter based on how many `--all` options were
     /// given: one will show dotfiles, but two will show `.` and `..` too.
+    /// --almost-all is equivalent to --all, included for compatibility with
+    /// `ls -A`.
     ///
-    /// It also checks for the `--tree` option in strict mode, because of a
-    /// special case where `--tree --all --all` won’t work: listing the
-    /// parent directory in tree mode would loop onto itself!
+    /// It also checks for the `--tree` option, because of a special case
+    /// where `--tree --all --all` won’t work: listing the parent directory
+    /// in tree mode would loop onto itself!
+    ///
+    /// `--almost-all` binds stronger than multiple `--all` as we currently do not take the order
+    /// of arguments into account and it is the safer option (does not clash with `--tree`)
     pub fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
-        let count = matches.count(&flags::ALL);
-
-        if count == 0 {
-            Ok(Self::JustFiles)
-        }
-        else if count == 1 {
-            Ok(Self::Dotfiles)
-        }
-        else if matches.count(&flags::TREE) > 0 {
-            Err(OptionsError::TreeAllAll)
-        }
-        else if count >= 3 && matches.is_strict() {
-            Err(OptionsError::Conflict(&flags::ALL, &flags::ALL))
-        }
-        else {
-            Ok(Self::DotfilesAndDots)
+        let all_count = matches.count(&flags::ALL);
+        let has_almost_all = matches.has(&flags::ALMOST_ALL)?;
+
+        match (all_count, has_almost_all) {
+            (0, false) => Ok(Self::JustFiles),
+
+            // either a single --all or at least one --almost-all is given
+            (1, _) | (0, true) => Ok(Self::Dotfiles),
+            // more than one --all
+            (c, _) => if matches.count(&flags::TREE) > 0 {
+                Err(OptionsError::TreeAllAll)
+            } else if matches.is_strict() && c > 2 {
+                Err(OptionsError::Conflict(&flags::ALL, &flags::ALL))
+            } else {
+                Ok(Self::DotfilesAndDots)
+            },
         }
     }
 }
@@ -231,7 +236,7 @@ mod test {
                 use crate::options::test::parse_for_test;
                 use crate::options::test::Strictnesses::*;
 
-                static TEST_ARGS: &[&Arg] = &[ &flags::SORT, &flags::ALL, &flags::TREE, &flags::IGNORE_GLOB, &flags::GIT_IGNORE ];
+                static TEST_ARGS: &[&Arg] = &[ &flags::SORT, &flags::ALL, &flags::ALMOST_ALL, &flags::TREE, &flags::IGNORE_GLOB, &flags::GIT_IGNORE ];
                 for result in parse_for_test($inputs.as_ref(), TEST_ARGS, $stricts, |mf| $type::deduce(mf)) {
                     assert_eq!(result, $result);
                 }
@@ -246,7 +251,7 @@ mod test {
         test!(empty:         SortField <- [];                  Both => Ok(SortField::default()));
 
         // Sort field arguments
-        test!(one_arg:       SortField <- ["--sort=mod"];       Both => Ok(SortField::ModifiedDate));
+        test!(one_arg:       SortField <- ["--sort=mod"];      Both => Ok(SortField::ModifiedDate));
         test!(one_long:      SortField <- ["--sort=size"];     Both => Ok(SortField::Size));
         test!(one_short:     SortField <- ["-saccessed"];      Both => Ok(SortField::AccessedDate));
         test!(lowercase:     SortField <- ["--sort", "name"];  Both => Ok(SortField::Name(SortCase::AaBbCc)));
@@ -275,20 +280,25 @@ mod test {
         use super::*;
 
         // Default behaviour
-        test!(empty:      DotFilter <- [];               Both => Ok(DotFilter::JustFiles));
+        test!(empty:        DotFilter <- [];               Both => Ok(DotFilter::JustFiles));
 
         // --all
-        test!(all:        DotFilter <- ["--all"];        Both => Ok(DotFilter::Dotfiles));
-        test!(all_all:    DotFilter <- ["--all", "-a"];  Both => Ok(DotFilter::DotfilesAndDots));
-        test!(all_all_2:  DotFilter <- ["-aa"];          Both => Ok(DotFilter::DotfilesAndDots));
+        test!(all:              DotFilter <- ["--all"];        Both => Ok(DotFilter::Dotfiles));
+        test!(all_all:          DotFilter <- ["--all", "-a"];  Both => Ok(DotFilter::DotfilesAndDots));
+        test!(all_all_2:        DotFilter <- ["-aa"];          Both => Ok(DotFilter::DotfilesAndDots));
 
-        test!(all_all_3:  DotFilter <- ["-aaa"];         Last => Ok(DotFilter::DotfilesAndDots));
-        test!(all_all_4:  DotFilter <- ["-aaa"];         Complain => Err(OptionsError::Conflict(&flags::ALL, &flags::ALL)));
+        test!(all_all_3:        DotFilter <- ["-aaa"];         Last => Ok(DotFilter::DotfilesAndDots));
+        test!(all_all_4:        DotFilter <- ["-aaa"];         Complain => Err(OptionsError::Conflict(&flags::ALL, &flags::ALL)));
 
         // --all and --tree
-        test!(tree_a:     DotFilter <- ["-Ta"];          Both => Ok(DotFilter::Dotfiles));
-        test!(tree_aa:    DotFilter <- ["-Taa"];         Both => Err(OptionsError::TreeAllAll));
-        test!(tree_aaa:   DotFilter <- ["-Taaa"];        Both => Err(OptionsError::TreeAllAll));
+        test!(tree_a:           DotFilter <- ["-Ta"];          Both => Ok(DotFilter::Dotfiles));
+        test!(tree_aa:          DotFilter <- ["-Taa"];         Both => Err(OptionsError::TreeAllAll));
+        test!(tree_aaa:         DotFilter <- ["-Taaa"];        Both => Err(OptionsError::TreeAllAll));
+
+        // --almost-all
+        test!(almost_all:       DotFilter <- ["--almost-all"]; Both => Ok(DotFilter::Dotfiles));
+        test!(almost_all_all:   DotFilter <- ["-Aa"];          Both => Ok(DotFilter::Dotfiles));
+        test!(almost_all_all_2: DotFilter <- ["-Aaa"];         Both => Ok(DotFilter::DotfilesAndDots));
     }
 
 

+ 3 - 2
src/options/flags.rs

@@ -23,6 +23,7 @@ pub static COLOUR_SCALE: Arg = Arg { short: None, long: "colour-scale", takes_va
 
 // filtering and sorting options
 pub static ALL:         Arg = Arg { short: Some(b'a'), long: "all",         takes_value: TakesValue::Forbidden };
+pub static ALMOST_ALL:  Arg = Arg { short: Some(b'A'), long: "almost-all",  takes_value: TakesValue::Forbidden };
 pub static LIST_DIRS:   Arg = Arg { short: Some(b'd'), long: "list-dirs",   takes_value: TakesValue::Forbidden };
 pub static LEVEL:       Arg = Arg { short: Some(b'L'), long: "level",       takes_value: TakesValue::Necessary(None) };
 pub static REVERSE:     Arg = Arg { short: Some(b'r'), long: "reverse",     takes_value: TakesValue::Forbidden };
@@ -53,7 +54,7 @@ pub static CREATED:    Arg = Arg { short: Some(b'U'), long: "created",    takes_
 pub static TIME_STYLE: Arg = Arg { short: None,       long: "time-style", takes_value: TakesValue::Necessary(Some(TIME_STYLES)) };
 pub static HYPERLINK:  Arg = Arg { short: None,       long: "hyperlink",  takes_value: TakesValue::Forbidden};
 const TIMES: Values = &["modified", "changed", "accessed", "created"];
-const TIME_STYLES: Values = &["default", "long-iso", "full-iso", "iso"];
+const TIME_STYLES: Values = &["default", "long-iso", "full-iso", "iso", "relative"];
 
 // suppressing columns
 pub static NO_PERMISSIONS: Arg = Arg { short: None, long: "no-permissions", takes_value: TakesValue::Forbidden };
@@ -77,7 +78,7 @@ pub static ALL_ARGS: Args = Args(&[
     &ONE_LINE, &LONG, &GRID, &ACROSS, &RECURSE, &TREE, &CLASSIFY,
     &COLOR, &COLOUR, &COLOR_SCALE, &COLOUR_SCALE,
 
-    &ALL, &LIST_DIRS, &LEVEL, &REVERSE, &SORT, &DIRS_FIRST,
+    &ALL, &ALMOST_ALL, &LIST_DIRS, &LEVEL, &REVERSE, &SORT, &DIRS_FIRST,
     &IGNORE_GLOB, &GIT_IGNORE, &ONLY_DIRS,
 
     &BINARY, &BYTES, &GROUP, &NUMERIC, &HEADER, &ICONS, &INODE, &LINKS, &MODIFIED, &CHANGED,

+ 1 - 1
src/options/help.rs

@@ -55,7 +55,7 @@ LONG VIEW OPTIONS
   -u, --accessed           use the accessed timestamp field
   -U, --created            use the created timestamp field
   --changed                use the changed timestamp field
-  --time-style             how to format timestamps (default, iso, long-iso, full-iso)
+  --time-style             how to format timestamps (default, iso, long-iso, full-iso, relative)
   --no-permissions         suppress the permissions field
   -o, --octal-permissions  list each file's permission in octal format
   --no-filesize            suppress the filesize field

+ 8 - 14
src/options/view.rs

@@ -260,20 +260,13 @@ impl TimeFormat {
                 }
             };
 
-        if &word == "default" {
-            Ok(Self::DefaultFormat)
-        }
-        else if &word == "iso" {
-            Ok(Self::ISOFormat)
-        }
-        else if &word == "long-iso" {
-            Ok(Self::LongISO)
-        }
-        else if &word == "full-iso" {
-            Ok(Self::FullISO)
-        }
-        else {
-            Err(OptionsError::BadArgument(&flags::TIME_STYLE, word))
+        match word.to_string_lossy().as_ref() {
+            "default"  => Ok(Self::DefaultFormat),
+            "relative" => Ok(Self::Relative),
+            "iso"      => Ok(Self::ISOFormat),
+            "long-iso" => Ok(Self::LongISO),
+            "full-iso" => Ok(Self::FullISO),
+            _ => Err(OptionsError::BadArgument(&flags::TIME_STYLE, word))
         }
     }
 }
@@ -470,6 +463,7 @@ mod test {
         // Individual settings
         test!(default:   TimeFormat <- ["--time-style=default"], None;      Both => like Ok(TimeFormat::DefaultFormat));
         test!(iso:       TimeFormat <- ["--time-style", "iso"], None;       Both => like Ok(TimeFormat::ISOFormat));
+        test!(relative:  TimeFormat <- ["--time-style", "relative"], None;  Both => like Ok(TimeFormat::Relative));
         test!(long_iso:  TimeFormat <- ["--time-style=long-iso"], None;     Both => like Ok(TimeFormat::LongISO));
         test!(full_iso:  TimeFormat <- ["--time-style", "full-iso"], None;  Both => like Ok(TimeFormat::FullISO));
 

+ 5 - 1
src/output/icons.rs

@@ -57,6 +57,7 @@ lazy_static! {
         m.insert(".gitconfig", '\u{f1d3}'); // 
         m.insert(".github", '\u{f408}'); // 
         m.insert(".gitignore", '\u{f1d3}'); // 
+        m.insert(".gitignore_global", '\u{f1d3}'); // 
         m.insert(".gitmodules", '\u{f1d3}'); // 
         m.insert(".rvm", '\u{e21e}'); // 
         m.insert(".vimrc", '\u{e62b}'); // 
@@ -67,6 +68,7 @@ lazy_static! {
         m.insert("config", '\u{e5fc}'); // 
         m.insert("docker-compose.yml", '\u{f308}'); // 
         m.insert("Dockerfile", '\u{f308}'); // 
+        m.insert("Earthfile", '\u{f30d}'); // 🌍
         m.insert("ds_store", '\u{f179}'); // 
         m.insert("gitignore_global", '\u{f1d3}'); // 
         m.insert("go.mod", '\u{e626}'); // 
@@ -88,6 +90,7 @@ lazy_static! {
         m.insert("PKGBUILD", '\u{f303}'); // 
         m.insert("rubydoc", '\u{e73b}'); // 
         m.insert("yarn.lock", '\u{e718}'); // 
+        m.insert("Vagrantfile", '\u{2371}'); //⍱
 
         m
     };
@@ -102,7 +105,7 @@ pub fn icon_for_file(file: &File<'_>) -> char {
             "bin"           => '\u{e5fc}', // 
             ".git"          => '\u{f1d3}', // 
             ".idea"         => '\u{e7b5}', // 
-            _               => '\u{f115}'  // 
+            _               => '\u{f413}'  // 
         }
     }
     else if let Some(icon) = extensions.icon_file(file) { icon }
@@ -360,6 +363,7 @@ pub fn icon_for_file(file: &File<'_>) -> char {
             "xz"            => '\u{f410}', // 
             "yaml"          => '\u{f481}', // 
             "yml"           => '\u{f481}', // 
+            "zig"           => '\u{21af}', // ↯
             "zip"           => '\u{f410}', // 
             "zsh"           => '\u{f489}', // 
             "zsh-theme"     => '\u{f489}', // 

+ 1 - 0
src/output/table.rs

@@ -177,6 +177,7 @@ impl Column {
             Self::Inode      |
             Self::Blocks     |
             Self::GitStatus  => Alignment::Right,
+            Self::Timestamp(_) | 
             _                => Alignment::Left,
         }
     }

+ 23 - 2
src/output/time.rs

@@ -1,8 +1,10 @@
 //! Timestamp formatting.
 
-use std::time::{SystemTime, UNIX_EPOCH};
+use std::convert::TryInto;
+use std::cmp::max;
+use std::time::{SystemTime, UNIX_EPOCH, Duration};
 
-use datetime::{LocalDateTime, TimeZone, DatePiece, TimePiece};
+use datetime::{LocalDateTime, TimeZone, DatePiece, TimePiece, Instant};
 use datetime::fmt::DateFormat;
 
 use lazy_static::lazy_static;
@@ -46,6 +48,9 @@ pub enum TimeFormat {
     /// millisecond and includes its offset down to the minute. This too uses
     /// only numbers so doesn’t require any special consideration.
     FullISO,
+
+    /// Use a relative but fixed width representation.
+    Relative,
 }
 
 // There are two different formatting functions because local and zoned
@@ -58,6 +63,7 @@ impl TimeFormat {
             Self::ISOFormat      => iso_local(time),
             Self::LongISO        => long_local(time),
             Self::FullISO        => full_local(time),
+            Self::Relative       => relative(time),
         }
     }
 
@@ -67,6 +73,7 @@ impl TimeFormat {
             Self::ISOFormat      => iso_zoned(time, zone),
             Self::LongISO        => long_zoned(time, zone),
             Self::FullISO        => full_zoned(time, zone),
+            Self::Relative       => relative(time),
         }
     }
 }
@@ -113,6 +120,20 @@ fn long_zoned(time: SystemTime, zone: &TimeZone) -> String {
             date.hour(), date.minute())
 }
 
+#[allow(trivial_numeric_casts)]
+fn relative(time: SystemTime) -> String {
+    timeago::Formatter::new()
+        .ago("")
+        .convert(
+            Duration::from_secs(
+                max(0, Instant::now().seconds() - systemtime_epoch(time))
+                // this .unwrap is safe since the call above can never result in a 
+                // value < 0
+                .try_into().unwrap()
+            )
+        )
+}
+
 #[allow(trivial_numeric_casts)]
 fn full_local(time: SystemTime) -> String {
     let date = LocalDateTime::at(systemtime_epoch(time));

+ 1 - 2
treefmt.nix

@@ -1,8 +1,7 @@
 {
   projectRootFile = "Cargo.toml";
   programs = {
-    # alejandra.enable = true;
+    alejandra.enable = true;
     rustfmt.enable = true;
   };
 }
-

+ 15 - 0
xtests/details-view-dates.toml

@@ -35,6 +35,13 @@ stderr = { empty = true }
 status = 0
 tags = [ 'long', 'time' ]
 
+[[cmd]]
+name = "‘exa -l --time-style=relative’ handles dates far past and future dates"
+shell = "exa -l --time-style=relative /testcases/far-dates"
+stdout = { file = "outputs/far_dates_relative.ansitxt" }
+stderr = { empty = true }
+status = 0
+tags = [ 'long', 'time' ]
 
 # alternate date formats
 
@@ -46,6 +53,14 @@ stderr = { empty = true }
 status = 0
 tags = [ 'long', 'time-style' ]
 
+[[cmd]]
+name = "‘exa -l --time-style=relative’ produces a table using the relative date format"
+shell = "exa -l --time-style=relative /testcases/dates"
+stdout = { file = "outputs/dates_long_timestyle_relative.ansitxt" }
+stderr = { empty = true }
+status = 0
+tags = [ 'long', 'time-style' ]
+
 [[cmd]]
 name = "‘exa -l --time-style=full-iso’ produces a table using the full-iso date format"
 shell = "exa -l --time-style=full-iso /testcases/dates"

+ 1 - 1
xtests/input-options.toml

@@ -42,7 +42,7 @@ tags = [ 'options' ]
 name = "exa displays an error for option that takes the wrong parameter"
 shell = "exa -l --time-style=24"
 stdout = { empty = true }
-stderr = { string = "Option --time-style has no \"24\" setting (choices: default, long-iso, full-iso, iso)" }
+stderr = { string = "Option --time-style has no \"24\" setting (choices: default, long-iso, full-iso, iso, relative)" }
 status = 3
 tags = [ 'options' ]
 

+ 3 - 0
xtests/outputs/dates_long_timestyle_relative.ansitxt

@@ -0,0 +1,3 @@
+.rw-rw-r-- 0 cassowary 15 years peach
+.rw-rw-r-- 0 cassowary 19 years pear
+.rw-rw-r-- 0 cassowary 12 years plum

+ 2 - 0
xtests/outputs/far_dates_relative.ansitxt

@@ -0,0 +1,2 @@
+.rw-rw-r-- 0 vagrant now beyond-the-future
+.rw-rw-r-- 0 vagrant now the-distant-past

+ 1 - 1
xtests/outputs/help.ansitxt

@@ -46,7 +46,7 @@ LONG VIEW OPTIONS
   -u, --accessed           use the accessed timestamp field
   -U, --created            use the created timestamp field
   --changed                use the changed timestamp field
-  --time-style             how to format timestamps (default, iso, long-iso, full-iso)
+  --time-style             how to format timestamps (default, iso, long-iso, full-iso, relative)
   --no-permissions         suppress the permissions field
   -o, --octal-permissions  list each file's permission in octal format
   --no-filesize            suppress the filesize field