Skip to content

add --mime-type(-m) to ls in the type column#7616

Merged
fdncred merged 1 commit intonushell:mainfrom
fdncred:add_mime_type_to_ls
Dec 27, 2022
Merged

add --mime-type(-m) to ls in the type column#7616
fdncred merged 1 commit intonushell:mainfrom
fdncred:add_mime_type_to_ls

Conversation

@fdncred
Copy link
Copy Markdown
Contributor

@fdncred fdncred commented Dec 27, 2022

Description

This PR adds the mime-type to the type column if you add the --mime-type(-m) flag to ls.
Screenshot 2022-12-27 at 11 43 20 AM

Screenshot 2022-12-27 at 11 45 53 AM

User-Facing Changes

If you specify the -m flag, you get the "guessed at" mime type. The guess is based on the file name and uses this crate https://docs.rs/mime_guess/latest/mime_guess/ for the guessing.

Part of issue #7612 and and #7524

There's some debate on if the mime-type should be added to the type column or if there should be a separate mime column. I tend to lean on the side of type since it's technically a type and it's only in that column if you ask it to be there. Also, I'd prefer to reuse a column rather than having a list of sprawling columns. Also, as @KodiCraft suggested, there is precedence as with ls -d where the summed size is in the size column.

I could go either way and if someone wants to create a mime column, we'd probably accept it.

Tests + Formatting

Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

  • cargo fmt --all -- --check to check standard code formatting (cargo fmt --all applies these changes)
  • cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

@fdncred fdncred merged commit db06edc into nushell:main Dec 27, 2022
@fdncred fdncred deleted the add_mime_type_to_ls branch December 27, 2022 18:46
sholderbach added a commit to nushell/nushell.github.io that referenced this pull request Dec 27, 2022
sholderbach added a commit to nushell/nushell.github.io that referenced this pull request Jan 10, 2023
* [WIP] Release notes for `0.74`

Please add your important new features and breaking changes to the release notes by committing to/opening a PR against the `release-notes-0.73` branch. Thank you!

* Start work on 0.74 release notes

* Mention mimetype flag from Darren

Refer to nushell/nushell#7616

* Update 2023-01-10-nushell_0_74.md

* Add image; Fmt (#718)

* Update 2023-01-10-nushell_0_74.md

* type-o

* Update 2023-01-10-nushell_0_74.md

* Add webbedspace's changes (#727)

* Add hide command breaking change

* Remove broken PATH mention

The PR changing append/prepend commands was reverted.

* Add `math eval` removal

* Mention `url encode`

* Mention get/select changes in breaking changes

* update changelog (#733)

* Update 2023-01-10-nushell_0_74.md

* Add new book chapter note

* Refactor breaking changes

* Update 2023-01-10-nushell_0_74.md

* Add detailed changelog

* Update excerpt

Co-authored-by: Jakub Žádník <kubouch@gmail.com>
Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
Co-authored-by: Leon <L_1_L_0@yahoo.com>
Co-authored-by: Reilly Wood <26268125+rgwood@users.noreply.github.com>
Co-authored-by: WindSoilder <WindSoilder@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant