mirror of
https://github.com/Llewellynvdm/exa.git
synced 2025-01-11 16:34:26 +00:00
Add number of hard links column
This is behaviour cribbed from ls. Even though I've never personally used it, I'm sure someone has a use for it.
This commit is contained in:
parent
8839cf4ca5
commit
fc8f8d6c6a
@ -4,6 +4,7 @@ pub enum Column {
|
||||
FileSize(bool),
|
||||
User(u64),
|
||||
Group,
|
||||
HardLinks,
|
||||
}
|
||||
|
||||
// Each column can pick its own alignment. Usually, numbers are
|
||||
@ -17,6 +18,7 @@ impl Column {
|
||||
pub fn alignment(&self) -> Alignment {
|
||||
match *self {
|
||||
FileSize(_) => Right,
|
||||
HardLinks => Right,
|
||||
_ => Left,
|
||||
}
|
||||
}
|
||||
|
3
file.rs
3
file.rs
@ -2,7 +2,7 @@ use colours::{Plain, Style, Black, Red, Green, Yellow, Blue, Purple, Cyan, Fixed
|
||||
use std::io::{fs, IoResult};
|
||||
use std::io;
|
||||
|
||||
use column::{Column, Permissions, FileName, FileSize, User, Group};
|
||||
use column::{Column, Permissions, FileName, FileSize, User, Group, HardLinks};
|
||||
use format::{format_metric_bytes, format_IEC_bytes};
|
||||
use unix::Unix;
|
||||
use sort::SortPart;
|
||||
@ -94,6 +94,7 @@ impl<'a> File<'a> {
|
||||
Permissions => self.permissions_string(),
|
||||
FileName => self.file_name(),
|
||||
FileSize(use_iec) => self.file_size(use_iec),
|
||||
HardLinks => Red.paint(self.stat.unstable.nlink.to_str().as_slice()),
|
||||
|
||||
// Display the ID if the user/group doesn't exist, which
|
||||
// usually means it was deleted but its files weren't.
|
||||
|
16
options.rs
16
options.rs
@ -2,7 +2,7 @@ extern crate getopts;
|
||||
|
||||
use file::File;
|
||||
use std::cmp::lexical_ordering;
|
||||
use column::{Column, Permissions, FileName, FileSize, User, Group};
|
||||
use column::{Column, Permissions, FileName, FileSize, User, Group, HardLinks};
|
||||
use unix::get_current_user_id;
|
||||
use std::ascii::StrAsciiExt;
|
||||
|
||||
@ -35,6 +35,7 @@ impl Options {
|
||||
getopts::optflag("a", "all", "show dot-files"),
|
||||
getopts::optflag("b", "binary", "use binary prefixes in file sizes"),
|
||||
getopts::optflag("g", "group", "show group as well as user"),
|
||||
getopts::optflag("l", "links", "show number of hard links"),
|
||||
getopts::optflag("r", "reverse", "reverse order of files"),
|
||||
getopts::optopt("s", "sort", "field to sort by", "WORD"),
|
||||
];
|
||||
@ -52,11 +53,14 @@ impl Options {
|
||||
}
|
||||
|
||||
fn columns(matches: getopts::Matches) -> Vec<Column> {
|
||||
let mut columns = vec![
|
||||
Permissions,
|
||||
FileSize(matches.opt_present("binary")),
|
||||
User(get_current_user_id()),
|
||||
];
|
||||
let mut columns = vec![Permissions];
|
||||
|
||||
if matches.opt_present("links") {
|
||||
columns.push(HardLinks);
|
||||
}
|
||||
|
||||
columns.push(FileSize(matches.opt_present("binary")));
|
||||
columns.push(User(get_current_user_id()));
|
||||
|
||||
if matches.opt_present("group") {
|
||||
columns.push(Group);
|
||||
|
Loading…
Reference in New Issue
Block a user