Commit Graph

922 Commits

Author SHA1 Message Date
Stuart Carnie
765fcf64c9
Update src/output/icons.rs
Co-authored-by: Mélanie Chauvel <perso@hack-libre.org>
2021-02-28 07:43:42 +11:00
Stuart Carnie
c42e0b3945
feat: New Icons and CLI argument to suppress icons 2021-02-28 07:18:17 +11:00
whonore
2708360fb5 Apply sort order to line and grid outputs. Fix #404 2021-01-14 10:01:27 -05:00
Mélanie Chauvel
13b91cced4
Merge pull request #772 from 0xflotus/patch-2 2021-01-14 14:29:34 +01:00
0xflotus
d11ac5d49b
Recognize SCSS and Stylus as source for CSS files (#770) 2021-01-14 13:54:45 +01:00
ariasuni
0f414cf0b9 Don’t produce extra column sometimes with long grid + header
The number of necessary columns was computed by producing a grid in different sizes and see if all columns were used. However, if there was two files and we tried to fit them in a 3-column grid, it would produces three headers and all three columns would be used; when trying a 4-column grid, the two supplementary headers would fill the third column and the fourth would be empty; so 3 columns would be used.

Now, when the grid fits into the terminal and the number of columns is exactly the number of files to display, it returns immediately instead of trying bigger grids.

Fixes GH-436.
2021-01-12 20:18:19 +01:00
ariasuni
79bac416f6 Use same styling for spaces between icon and file name
This is only visible when selecting both icon and file name, as most terminal emulators then invert background and foreground color.

It also workaround a Konsole bug: https://bugs.kde.org/show_bug.cgi?id=422776
2021-01-03 22:44:16 +01:00
0xflotus
7b15f32da8
feat: add support Typescript and ReasonML projects
Close #771
2020-12-16 00:08:04 +01:00
ariasuni
42bc34f339 Tell if exa was compiled with git support or not when using --help 2020-12-10 19:29:33 +01:00
ariasuni
a740512014 Warm when git feature is disabled instead of ignoring flags
The flags --git and --git-ignore are caught early during options parsing, so no more checking for git feature is done elsewhere.

Since --git-ignore depends on git too since recently, remove it from help when git feature is disabled.

Extended attributes now don’t artificially depends on git feature being enabled.
2020-12-10 18:48:58 +01:00
Benjamin Sago
51be9f4c43 Introduce EXA_ICON_SPACING environment variable
This commit remove the extra space that was added between icons and file names in commit 128fadd, and adds an option to put them back.

Re-fixes GH-619 and fixes GH-541.
2020-10-24 19:41:07 +01:00
Benjamin Sago
976db01b3e Prefer background colour when painting icons
The rationale here is that there's more of a background colour than the foreground colour when painting text, and having a gap of no background colour in between the icon and the file name looks weird.

Fixes GH-561.
2020-10-24 18:29:28 +01:00
Benjamin Sago
67a6cdd46a Make icon styles appropriate for all file types
exa now bases the icon style for a file on its file name and kind in all cases, rather than just on its file name. This means that directories and symlinks have the correctly-coloured icon.

It also only takes the foreground colour into account while styling the icon, to make sure they're not bold or underlined.

Fixes GH-528.
2020-10-24 18:16:38 +01:00
Benjamin Sago
f1e3e7c7ff Move icon generation into file name module
This commit makes adding icons to file names something that the file name renderer does, rather than something that each individual view does. This is now possible thanks to the previous commit a1869f2, which moved the option to do this into the same module. The repeated code has been removed.

It happens to fix a bug where the width of each column was being incorrectly calculated for the grid-details view, making lines slightly too long for the terminal because the icon wasn't being taken into account.
2020-10-24 18:03:36 +01:00
Benjamin Sago
a1869f208e Move common icons option to file style struct
All four of the view mode command-line argument parsers tested for the --icons option. Because it was common, the behaviour has been moved to the struct that handles file styles, meaning it can be parsed in one place.

This is a better place for it, as the icons are to do with the file name, not the view. It also means that the lines view has no options left for it, which is fitting.
2020-10-23 23:57:10 +01:00
Benjamin Sago
fd730e436c Make View command-line args position-dependent
This commit changes the way the View (long mode, lines mode, grid mode, etc) is parsed from the command-line arguments.

Previously, it checked for long and long-grid, then tree, then lines, then grid, in that order, no matter which order the arguments were given in on the command-line. Now, it bases the view on whichever argument comes last in the list.

Unfortunately, the options-parsing code for Views is getting really complicated, but I can't see a way to simplify it while retaining the existing functionality.

It also links the parsing of DirAction to the result of parsing the View, so that you can't use tree mode if your view isn't Details. This is to fix an issue where `exa --tree --oneline` would just emit ".", because the DirAction was treating directories as files, and the argument was ".", and the View made it use lines view. Now, the --tree is ignored, as the view isn't Details.

Fixes GH-407 and GH-583.
2020-10-23 23:04:22 +01:00
Benjamin Sago
bf3d58aa80 a small formatting change 2020-10-23 22:32:16 +01:00
Benjamin Sago
3419afa7cf Massive theming and view options refactor
This commit significantly refactors the way that options are parsed. It introduces the Theme type which contains both styling and extension configuration, converts the option-parsing process into a being a pure function, and removes some rather gnarly old code.

The main purpose of the refactoring is to fix GH-318, "Tests fail when not connected to a terminal". Even though exa was compiling fine on my machine and on Travis, it was failing for automated build scripts. This was because of what the option-parsing code was trying to accomplish: it wasn't just providing a struct of the user's settings, it was also checking the terminal, providing a View directly.

This has been changed so that the options module now _only_ looks at the command-line arguments and environment variables. Instead of returning a View, it returns the user's _preference_, and it's then up to the 'main' module to examine the terminal width and figure out if the view is doable, downgrading it if necessary.

The code that used to determine the view was horrible and I'm pleased it can be cut out. Also, the terminal width used to be in a lazy_static because it was queried multiple times, and now it's not in one because it's only queried once, which is a good sign for things going in the right direction.

There are also some naming and organisational changes around themes. The blanket terms "Colours" and "Styles" have been yeeted in favour of "Theme", which handles both extensions and UI colours. The FileStyle struct has been replaced with file_name::Options, making it similar to the views in how it has an Options struct and a Render struct.

Finally, eight unit tests have been removed because they turned out to be redundant (testing --colour and --color) after examining the tangled code, and the default theme has been put in its own file in preparation for more themes.
2020-10-22 22:34:00 +01:00
Benjamin Sago
eb90b4d168 Ignore --across --long conflict not in strict mode
Fixes #476.
2020-10-20 22:48:05 +01:00
Benjamin Sago
85414b2a61 Very slight test cleaning
I'm not 100% on the way these tests are laid out, but it _is_ helpful to see all the test data aligned like that.
2020-10-20 22:42:04 +01:00
Laurent Arnoud
bf883884ed
Add more immediate files 2020-10-18 10:41:44 +02:00
Benjamin Sago
86de17b788 Help text changes
This changes the --help text, and gets rid of the special behaviour for --help --long, which I thought was a really good idea at the time, but now I just think it's inconsistent and unexpected behaviour. --help should return the same help, no matter what other arguments you have typed.

Other things:
• Put --help and --version in a section
• Capitalisation consistency
• Alignment
• Move the --octal-permissions line up a bit
• Simplify the printing implementation (HelpString is now a unit struct)

This _finally_ makes all the extended tests pass.
2020-10-16 23:53:42 +01:00
Sudhip Nashi
42b9a5802e
Add extra coloring 2020-10-15 15:38:38 -05:00
Benjamin Sago
002080cde8 Clippy pedantic lints
This commit fixes a couple of Clippy warnings, and adds the list of lints we're OK with.

It does raise some important warnings, such as those to do with casting, which aren't allowed so they can be fixed later.
2020-10-13 01:46:17 +01:00
Benjamin Sago
3dc86c99ad New set of lints, and Rust 2018 idioms 2020-10-13 01:36:41 +01:00
Benjamin Sago
80f9806bbc Move Git shared state to structs
This was being passed around everywhere as a parameter, when it can exist just as nicely as a struct field. This means many functions can take one argument less.
2020-10-13 01:28:42 +01:00
Benjamin Sago
ecbe63bf1e IO import changes 2020-10-13 00:54:06 +01:00
Benjamin Sago
6f2d8cc26c Have tests use OsStrs not OsStrings 2020-10-13 00:29:49 +01:00
Benjamin Sago
ed59428cbc Replace Misfire with a testable OptionsResult
This was meant to be a small change, but it spiralled into a big one.

The original intention was to separate OptionsResult and OptionsError. With these types separated, the Help and Version variants can only be returned from the Options::parse function, and the later option-parsing functions can only return success or errors.

Also, Misfire was a silly name.

As a side-effect of Options::parse returning OptionsResult instead of Result<Options, Misfire>, we could no longer use unwrap() or unwrap_err() to get the contents out. This commit makes OptionsResult into a value type, and Options::parse a pure function. It feels like it should be one, having its return value entirely dependent on its arguments, but it also loaded locales and time zones. These parts have been moved into lazy_static references, and the code still passes tests without much change.

OptionsResult isn't PartialEq yet, because the file colouring uses a Box internally.
2020-10-12 23:47:36 +01:00
Benjamin Sago
f8df02dae7 Batch source formatting
I read through every file and applied a couple of rustfmt suggestions. The brace placement and alignment of items on similar lines has been made consistent, even if neither are rustfmt's default style (a file has been put in place to enforce this). Other changes are:

• Alphabetical imports and modules
• Comma placement at the end of match blocks
• Use newlines and indentation judiciously
• Spaces around associated types
• Spaces after negations (it makes it more clear imho)
• Comment formatting
• Use early-returns and Optional `?` where appropriate
2020-10-10 20:02:55 +01:00
Benjamin Sago
c3c39fee0a Various misc clippy fixes 2020-10-10 15:57:40 +01:00
Benjamin Sago
a25cfe765d Remove some enum glob imports
These are holdovers from how I used to write Rust ("back in the day" of 2014). There are still some places in the code where I think it's worth glob-importing enums, but not these places.
2020-10-10 15:46:39 +01:00
Benjamin Sago
f0c139ca68 Better referencing
This commit makes changes to the way variables are referenced:

• Make types Copy when possible
• Make methods take `self` instead of `&self` where possible (trivially_copy_pass_by_ref)
• Remove unnecessary borrowing (needless_ref)
• Remove unnecessary cloning (clone_on_copy)
• Remove `ref` from match arms where possible (new Rust match ergonomics)
2020-10-10 15:30:19 +01:00
Benjamin Sago
70a30ed683 The Selfening
This commit uses Clippy to fix all the 'use_self' warnings. Using Self instead of the type name has been good Rust style for a while now, and it's become the style I'm used to seeing.
2020-10-10 13:55:26 +01:00
Benjamin Sago
74d9f1402b Some Clippy fixes 2020-10-10 13:33:50 +01:00
Benjamin Sago
39c3f15602 Simplify type signatures in main module
Exa::from_args used to be in the library, called by the binary, but now the binary is gone, it no longer needs to be as abstract. Instead of accepting a reference to a Write value, it takes a Stdout directly, which it owns itself, simplifying the type signature drastically.
2020-10-10 02:35:23 +01:00
Benjamin Sago
8046980806 Mass version upgrade
This upgrades the versions of everything, including upgrading almost all outdated dependencies.

• number_prefix had some backwards-incompatible changes. It now feels more Rustful, and spells "Mebi" correctly.
• term_grid stopped working when I upgraded it, worryingly, so I reverted it back.
2020-10-10 02:14:35 +01:00
Benjamin Sago
04e2d4c692 Just straight-up roll our own logger
This commit removes the env_logger dependency, replacing it with a simple implementation. Doing so removes like ten other transitive dependencies that no longer need to be included in the build.

It also gains the ability to enable trace-level logging. The users crate, which contains such logging statements as of the version I published a few days ago, has been upgraded to celebrate.

Also, change the log imports to globs. I'm only interested that a file doing logging, not what level it's logging at.
2020-10-10 02:01:12 +01:00
Benjamin Sago
5ca3548bb1 Inline the library into the binary
This commit removes the library portion of exa. Cargo now only builds a binary.

The original intent was for exa to have its own internal library, and have the binary just call the library. This is usually done for code cleanliness reasons: it separates the code that implements the purpose of the program (the "plumbing") from the code that the user interacts with (the "porcelain"), ensuring a well-defined interface between the two.

However, in exa, this split was in completely the wrong place. Logging was handled in the binary, but option parsing was handled in the library. The library could theoretically print to any Writer ("for testing", it said), but it's far easier to run integration tests by executing the binary than to change the code to handle unit tests, so this abstraction isn't gaining us anything.

I've also had several people ask me if exa should be packaged for Linux distributions as a library, or just a binary. Clearly, this is confusing!

In several of my other Rust projects, I've done this better, with the command-line option parsing and log printing done on the binary side. It also turns out that you don't need to have a [lib] section in the Cargo.toml, so that's gone too.
2020-10-10 01:43:42 +01:00
Benjamin Sago
df81a24dae Use 0 and 1 rather than EXIT_SUCCESS/FAILURE
It doesn't seem right to use the EXIT_SUCCESS constant in one place, and a hard-coded 2 in another. What if they overlap?

Changing the success value to 0 should be OK, though, because the standard defines 0 as success, regardless of whether EXIT_SUCCESS is 0 or not.

Also, the values have become i32s. The Rust function std::process::exit takes an i32, so there's not much point using anything else.
2020-10-10 01:11:22 +01:00
Benjamin Sago
e44858eb41 Fix bug where files were Git-ignored too often
This was an unintended consequence of #653. The Files iterator stopped using IgnoreCache and started using GitCache, which would always populated when the `--git` option was passed, without checking whether files were meant to be ignored. This meant that passing `--git` started ignoring files even without `--git-ignore`.

The solution for now is to explicitly pass the flag around, which probably should be a better type than bool but isn't. This makes the git-ignoring-related extended tests pass.
2020-10-10 00:09:44 +01:00
Benjamin Sago
7f9773b68e Merge branch 'zachcoyle-add-nix-icon' 2020-10-08 22:56:24 +01:00
Benjamin Sago
fd3a3d13b7 Merge branch 'add-nix-icon' of https://github.com/zachcoyle/exa into zachcoyle-add-nix-icon
# Conflicts:
#	src/output/icons.rs
2020-10-08 22:56:16 +01:00
Benjamin Sago
dee447213c
Merge pull request #743 from jonhoo/patch-1
Add additional TeX compiled files
2020-10-08 22:43:24 +01:00
Benjamin Sago
c167046c34
Merge pull request #735 from Finermeerkat137/pull_req
add ko to compiled objects
2020-10-08 22:42:30 +01:00
Benjamin Sago
9240dbdef3
Merge pull request #734 from imsofi/master
Fix icons for symlinked directories
2020-10-08 22:41:59 +01:00
Benjamin Sago
6f20f195a7
Merge pull request #726 from 0x3333/master
Fixes #719. Change August to Aug.
2020-10-08 22:38:25 +01:00
Benjamin Sago
8b852cb201
Merge pull request #725 from kbravh/tz-variable-patch
Update determine_time_zone function to check TZ
2020-10-08 22:37:00 +01:00
Benjamin Sago
d03e39c367 Merge branch 'master' of https://github.com/JavaCafe01/exa into JavaCafe01-master
Change a bunch of the existing shell-related icons to the new Unicode escape.
# Conflicts:
#	src/output/icons.rs
2020-10-08 22:30:20 +01:00
Benjamin Sago
8c3748ca35 Merge branch 'DiegoMagdaleno-master' 2020-10-08 22:24:06 +01:00
Benjamin Sago
1ee8fab7de Merge branch 'master' of https://github.com/DiegoMagdaleno/exa into DiegoMagdaleno-master
# Conflicts:
#	src/output/icons.rs
2020-10-08 22:23:18 +01:00
Benjamin Sago
083cf147be
Merge pull request #709 from poliorcetics/add-apple-filetypes
Add the documents extension for Apple file formats
2020-10-08 22:17:45 +01:00
Benjamin Sago
dbbc4e465b
Merge pull request #704 from LarsHaalck/master
Add --octal-permissions argument
2020-10-08 22:14:38 +01:00
Benjamin Sago
ea62aab37e
Merge pull request #690 from schlessera/add/php-immediate-files
Add immediate file types for PHP ecosystem
2020-10-08 22:11:01 +01:00
Benjamin Sago
cba2070924
Merge pull request #678 from olshevskiy87/display_git_status_conflicted
git-feature: display if a file is updated but unmerged (conflicted)
2020-10-08 22:10:33 +01:00
Benjamin Sago
12e45ac41c Merge branch 'master' of https://github.com/danielbayley/exa into danielbayley-master
# Conflicts:
#	src/output/icons.rs
2020-10-08 22:00:36 +01:00
Benjamin Sago
d901bb289c
Merge pull request #654 from ariasuni/cleaning
Clean code a bit and fix typos in code documentation
2020-10-08 21:49:20 +01:00
Benjamin Sago
1fe06a7682
Merge pull request #653 from ariasuni/fix-gitignore-option
Use git2 instead of parsing .gitignore for --git-ignore
2020-10-08 21:46:10 +01:00
Jon Gjengset
c0f01310c4
Add bcf biblatex control file 2020-10-03 20:25:24 -04:00
Jon Gjengset
f37aeebef0
Add additional TeX compiled files
Specifically .fls and .fdb_latexmk, which the popular `latexmk` tool produces.
2020-10-03 19:46:06 -04:00
Zach Coyle
3b1d770f8a
Add Nix Icon 2020-09-26 23:36:24 -04:00
Sudhip Nashi
c17cf95f4c add ko to compiled objects 2020-09-12 21:15:57 -05:00
imsofi
0a7ffcd042
Fix icons for symlinked directories 2020-09-08 22:27:39 +02:00
Karey Higuera
5be0286749 deconstruct the TZ environment variable instead of unwrapping 2020-09-03 08:49:51 -04:00
Tercio Gaudencio Filho
3fe35b571f
Change August to Aug. Fix issue #719. 2020-08-28 15:05:57 -03:00
Karey Higuera
e8d69fc5e8 Update determine_time_zone function to check TZ
Instead of defaulting immediately to /etc/filename for the timezone, we can first check whether the TZ environment variable is set. If so, we can pull the corresponding timezone file from /usr/share/zoneinfo. Closes #453.
2020-08-26 19:31:48 -04:00
Gokul Swaminathan
43a4fcb27a Updated filetype icons
Added icon for filetype `.sh`
2020-08-14 01:11:44 -07:00
Diego Magdaleno
4085010b36
Add Swift Programming Language icon 2020-08-08 10:12:07 -05:00
Alexis Bourget
f872027cfe Add the documents extension for Apple file formats 2020-08-02 18:50:32 +02:00
Lars Haalck
16046d57de
Add --octal-permissions argument
Using --octal_permissions will insert another column before the existing
permissions where permissions are encoded using octal values as
requested in #316
2020-07-24 13:47:34 +02:00
Alain Schlesser
2ccc8fa093
Add immediate file types for PHP ecosystem
Added the following imemdiate file types for PHP:
- `composer.json` for [Composer](https://getcomposer.org/), the defactor standard package manager for PHP;
- `RoboFile.php`, for [Robo](https://robo.li/), the PHP task runner.

Note: [Phing]() uses `build.xml`, which was already included in the list.
2020-06-21 11:52:33 +02:00
Dmitriy Olshevskiy
45eade9a59 git-feature: display if a file is updated but unmerged (conflicted) 2020-05-29 17:23:22 +03:00
ariasuni
dba3f37b0a Fix Clippy lints 2020-05-24 21:43:55 +02:00
Thomas Hurst
acb7c49abf Improve handling of unavailable timestamps.
Previously if a timestamp was unavailable, it defaulted to the epoch.
Prior to this it defaulted to a zero duration.

Switch to an Option<SystemTime> and move the handling of unavailable
timestamps to rendering.
2020-05-19 02:31:15 +00:00
Thomas Hurst
e54e1f53c8 Make logic a little clearer 2020-05-18 23:23:30 +00:00
Thomas Hurst
86163ab298 Restore ctime handling with correct pre-epoch behaviour 2020-05-18 23:21:56 +00:00
Thomas Hurst
d2d2e7325f Correct handling of pre-epoch timestamps
Fix an off-by-one on the seconds when subseconds are present, and
correct display of nenoseconds, which are of course inverted due to the
internal value being negative.
2020-05-18 21:25:07 +00:00
Thomas Hurst
bc830b9158 Handle timestamps before UNIX_EPOCH (#658)
Instead of returning a Duration since the epoch from file metadata,
which cannot represent times before it, return the SystemTime directly.

Move conversion closer to where it's needed, and perform it infallibly.
2020-05-18 21:03:44 +00:00
Daniel Bayley
f018e093c7 Improve default file icon 2020-05-04 00:06:41 +01:00
ariasuni
5a84953b4e Fix typos in code documentation 2020-04-19 06:54:06 +02:00
ariasuni
046af5cdd1 Use git2 instead of parsing .gitignore for --git-ignore
Fix #636
2020-04-19 05:52:35 +02:00
Laurent Arnoud
bd655f9c20
Remove unused imports on fs/file.rs 2020-01-19 18:40:34 +01:00
Benjamin Sago
490d9680c2 Merge branch 'fix-handling-maybe-unsupported-time-metadata' of https://github.com/ariasuni/exa into ariasuni-fix-handling-maybe-unsupported-time-metadata
# Conflicts:
#	src/fs/file.rs
#	src/options/filter.rs
#	src/options/view.rs
2020-01-19 16:46:51 +00:00
Benjamin Sago
df0d30e966
Merge pull request #624 from ericbn/filetypes
Add pom.xml and zwc filetypes
2020-01-19 16:20:59 +00:00
Benjamin Sago
c46dfc8836
Merge pull request #619 from aeonzh/master
Better icons spacing
2020-01-19 16:17:13 +00:00
Eric Nielsen
501fbf7182 Add pom.xml and zwc filetypes
pom.xml (Maven) is popularly used for Java projects, along with the
already existing build.xml (Ant) and build.gradle (Gradle) immediate
files.

zwc stands for Zsh Word Code and contains compiled Z Shell scripts or
functions.
2020-01-19 09:08:07 -05:00
Benjamin Sago
eaece8cc7a
Merge branch 'master' into customize-size-scale-colours 2020-01-19 09:57:58 +00:00
Benjamin Sago
2382be7524
Merge branch 'master' into add-missing-flags-in-docs 2020-01-19 09:40:22 +00:00
Benjamin Sago
352afd40c3
Merge pull request #598 from FliegendeWurst/s-none-sorting
Optimize file table creation, fixes #484 as a side-effect
2020-01-19 09:32:17 +00:00
Benjamin Sago
416818fda2
Merge pull request #597 from FliegendeWurst/bugfixes
Two small bugfixes
2020-01-19 00:55:58 +00:00
Benjamin Sago
d13cce7d94
Merge pull request #593 from ariasuni/add-new-filetypes
Add a few frequent filetypes
2020-01-19 00:53:34 +00:00
Benjamin Sago
3d82fc7683
Merge pull request #587 from brown121407/master
Fix "trait objects without an explicit `dyn` are deprecated"
2020-01-19 00:50:32 +00:00
Benjamin Sago
64bd1b9a55
Merge pull request #584 from msehnout/fix-panic-on-broken-symlink
fix panic on broken symlink in git repository
2020-01-19 00:48:07 +00:00
Benjamin Sago
8a711358ee
Merge pull request #579 from ericbn/unused-code
Remove unused code in File#get_source_files
2020-01-19 00:42:44 +00:00
Benjamin Sago
1f167dda41
Merge pull request #577 from 0rvar/feature/suppress-columns
Add support for suppressing table columns
2020-01-19 00:41:27 +00:00
Benjamin Sago
5521f2d4ab
Merge pull request #560 from horosgrisa/master
Add some icons for files
2020-01-19 00:40:13 +00:00
Benjamin Sago
c5a1e8e103
Merge pull request #557 from BrennanMcDonald/master
Added checks for modified/accessed/created metadata
2020-01-19 00:39:40 +00:00
Benjamin Sago
404ed20fd3
Merge pull request #552 from j-tai/icons-1-col
Display icons when file names are too long for grid
2020-01-19 00:20:18 +00:00
Benjamin Sago
4dab6237f1
Merge pull request #516 from VichoReyes/dothidden
Include symlinks to dirs when grouping dirs
2020-01-19 00:16:06 +00:00
Benjamin Sago
e198cac3a7
Merge pull request #509 from emgelb/master
Convert default formatting so single-digit hour times are 0-padded
2020-01-19 00:05:07 +00:00