Skip to content

Commit

Permalink
Merge pull request #1 from ogham/master
Browse files Browse the repository at this point in the history
Pull latest from upstream
  • Loading branch information
daviessm committed Dec 8, 2018
2 parents abf3222 + 058b4a5 commit 02cfbe9
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 16 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ readme = "README.md"
categories = ["command-line-utilities"]
keywords = ["ls", "files", "command-line"]
license = "MIT"
exclude = ["/devtools/*", "/Makefile", "/Vagrantfile", "/screenshots.png"]


[[bin]]
Expand Down Expand Up @@ -41,7 +42,7 @@ scoped_threadpool = "0.1.*"
term_grid = "0.1.6"
term_size = "0.3.0"
unicode-width = "0.1.4"
users = "0.7"
users = "0.8"
zoneinfo_compiled = "0.4.7"

[build-dependencies]
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

[exa](https://the.exa.website/) is a replacement for `ls` written in Rust.

## Rationale

**exa** is a modern replacement for the command-line program ls that ships with Unix and Linux operating systems, with 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, exa attempts to be a more featureful, more user-friendly version of ls.

## Screenshots

![Screenshots of exa](screenshots.png)
Expand Down Expand Up @@ -52,7 +58,7 @@ These options are available when running with --long (`-l`):
- **-u**, **--accessed**: use the accessed timestamp field
- **-U**, **--created**: use the created timestamp field
- **-@**, **--extended**: list each file's extended attributes and sizes
- **--git**: list each file's Git status, if tracked
- **--git**: list each file's Git status, if tracked or ignored
- **--time-style**: how to format timestamps

- Valid **--color** options are **always**, **automatic**, and **never**.
Expand Down
1 change: 1 addition & 0 deletions src/fs/feature/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ fn working_tree_status(status: git2::Status) -> f::GitStatus {
s if s.contains(git2::Status::WT_DELETED) => f::GitStatus::Deleted,
s if s.contains(git2::Status::WT_RENAMED) => f::GitStatus::Renamed,
s if s.contains(git2::Status::WT_TYPECHANGE) => f::GitStatus::TypeChange,
s if s.contains(git2::Status::IGNORED) => f::GitStatus::Ignored,
_ => f::GitStatus::NotModified,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/fs/feature/xattr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ mod lister {
FollowSymlinks::No => 0x0000,
};

Lister { c_flags: c_flags }
Lister { c_flags }
}

pub fn translate_attribute_name(&self, input: &[u8]) -> String {
Expand Down
5 changes: 4 additions & 1 deletion src/fs/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub struct DeviceIDs {


/// One of a file’s timestamps (created, accessed, or modified).
#[derive(Copy, Clone)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct Time {
pub seconds: time_t,
pub nanoseconds: time_t,
Expand Down Expand Up @@ -197,6 +197,9 @@ pub enum GitStatus {

/// A file that’s had its type (such as the file permissions) changed.
TypeChange,

/// A file that’s ignored (that matches a line in .gitignore)
Ignored,
}

/// A file’s complete Git status. It’s possible to make changes to a file, add
Expand Down
8 changes: 4 additions & 4 deletions src/fs/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ impl SortField {

SortField::Size => a.metadata.len().cmp(&b.metadata.len()),
SortField::FileInode => a.metadata.ino().cmp(&b.metadata.ino()),
SortField::ModifiedDate => a.metadata.mtime().cmp(&b.metadata.mtime()),
SortField::AccessedDate => a.metadata.atime().cmp(&b.metadata.atime()),
SortField::CreatedDate => a.metadata.ctime().cmp(&b.metadata.ctime()),
SortField::ModifiedAge => b.metadata.mtime().cmp(&a.metadata.mtime()), // flip b and a
SortField::ModifiedDate => a.modified_time().cmp(&b.modified_time()),
SortField::AccessedDate => a.accessed_time().cmp(&b.accessed_time()),
SortField::CreatedDate => a.created_time().cmp(&b.created_time()),
SortField::ModifiedAge => b.modified_time().cmp(&a.modified_time()), // flip b and a

SortField::FileType => match a.type_char().cmp(&b.type_char()) { // todo: this recomputes
Ordering::Equal => natord::compare(&*a.name, &*b.name),
Expand Down
2 changes: 1 addition & 1 deletion src/options/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ LONG VIEW OPTIONS
-U, --created use the created timestamp field
--time-style how to format timestamps (default, iso, long-iso, full-iso)"##;

static GIT_HELP: &str = r##" --git list each file's Git status, if tracked"##;
static GIT_HELP: &str = r##" --git list each file's Git status, if tracked or ignored"##;
static EXTENDED_HELP: &str = r##" -@, --extended list each file's extended attributes and sizes"##;


Expand Down
3 changes: 3 additions & 0 deletions src/output/render/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ impl f::GitStatus {
f::GitStatus::Deleted => colours.deleted().paint("D"),
f::GitStatus::Renamed => colours.renamed().paint("R"),
f::GitStatus::TypeChange => colours.type_change().paint("T"),
f::GitStatus::Ignored => colours.ignored().paint("I"),
}
}
}
Expand All @@ -38,6 +39,7 @@ pub trait Colours {
fn deleted(&self) -> Style;
fn renamed(&self) -> Style;
fn type_change(&self) -> Style;
fn ignored(&self) -> Style;
}


Expand All @@ -60,6 +62,7 @@ pub mod test {
fn deleted(&self) -> Style { Fixed(93).normal() }
fn renamed(&self) -> Style { Fixed(94).normal() }
fn type_change(&self) -> Style { Fixed(95).normal() }
fn ignored(&self) -> Style { Fixed(96).normal() }
}


Expand Down
4 changes: 2 additions & 2 deletions src/output/render/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ impl f::Group {
let current_uid = users.get_current_uid();
if let Some(current_user) = users.get_user_by_uid(current_uid) {
if current_user.primary_group_id() == group.gid()
|| group.members().contains(&current_user.name().to_owned()) {
|| group.members().iter().any(|u| u == current_user.name()) {
style = colours.yours();
}
}

TextCell::paint(style, group.name().to_owned())
TextCell::paint(style, group.name().to_string_lossy().into())
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/output/render/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use output::cell::TextCell;
impl f::User {
pub fn render<C: Colours, U: Users>(&self, colours: &C, users: &U) -> TextCell {
let user_name = match users.get_user_by_uid(self.0) {
Some(user) => user.name().to_owned(),
Some(user) => user.name().to_string_lossy().into(),
None => self.0.to_string(),
};

Expand Down
4 changes: 3 additions & 1 deletion src/style/colours.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ pub struct Git {
pub deleted: Style,
pub renamed: Style,
pub typechange: Style,
pub ignored: Style,
}

impl Colours {
Expand Down Expand Up @@ -177,6 +178,7 @@ impl Colours {
deleted: Red.normal(),
renamed: Yellow.normal(),
typechange: Purple.normal(),
ignored: Style::default().dimmed(),
},

punctuation: Fixed(244).normal(),
Expand Down Expand Up @@ -326,6 +328,7 @@ impl render::GitColours for Colours {
fn deleted(&self) -> Style { self.git.deleted }
fn renamed(&self) -> Style { self.git.renamed }
fn type_change(&self) -> Style { self.git.typechange }
fn ignored(&self) -> Style { self.git.ignored }
}

impl render::GroupColours for Colours {
Expand Down Expand Up @@ -400,4 +403,3 @@ impl FileNameColours for Colours {
fn symlink_path(&self) -> Style { self.symlink_path }
fn executable_file(&self) -> Style { self.filekinds.executable }
}

0 comments on commit 02cfbe9

Please sign in to comment.