mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-05-29 05:40:47 +00:00
Add number of blocks column
This commit is contained in:
parent
19e0f9b70d
commit
48284e0aef
|
@ -2,6 +2,7 @@ pub enum Column {
|
|||
Permissions,
|
||||
FileName,
|
||||
FileSize(bool),
|
||||
Blocks,
|
||||
User(u64),
|
||||
Group,
|
||||
HardLinks,
|
||||
|
@ -21,6 +22,7 @@ impl Column {
|
|||
FileSize(_) => Right,
|
||||
HardLinks => Right,
|
||||
Inode => Right,
|
||||
Blocks => Right,
|
||||
_ => Left,
|
||||
}
|
||||
}
|
||||
|
|
12
file.rs
12
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, HardLinks, Inode};
|
||||
use column::{Column, Permissions, FileName, FileSize, User, Group, HardLinks, Inode, Blocks};
|
||||
use format::{format_metric_bytes, format_IEC_bytes};
|
||||
use unix::Unix;
|
||||
use sort::SortPart;
|
||||
|
@ -96,6 +96,14 @@ impl<'a> File<'a> {
|
|||
FileSize(use_iec) => self.file_size(use_iec),
|
||||
HardLinks => Red.paint(self.stat.unstable.nlink.to_str().as_slice()),
|
||||
Inode => Purple.paint(self.stat.unstable.inode.to_str().as_slice()),
|
||||
Blocks => {
|
||||
if self.stat.kind == io::TypeFile || self.stat.kind == io::TypeSymlink {
|
||||
Cyan.paint(self.stat.unstable.blocks.to_str().as_slice())
|
||||
}
|
||||
else {
|
||||
Fixed(244).paint("-")
|
||||
}
|
||||
},
|
||||
|
||||
// Display the ID if the user/group doesn't exist, which
|
||||
// usually means it was deleted but its files weren't.
|
||||
|
@ -151,7 +159,7 @@ impl<'a> File<'a> {
|
|||
// Don't report file sizes for directories. I've never looked
|
||||
// at one of those numbers and gained any information from it.
|
||||
if self.stat.kind == io::TypeDirectory {
|
||||
Black.bold().paint("-")
|
||||
Fixed(244).paint("-")
|
||||
} else {
|
||||
let (size, suffix) = if use_iec_prefixes {
|
||||
format_IEC_bytes(self.stat.size)
|
||||
|
|
|
@ -2,7 +2,7 @@ extern crate getopts;
|
|||
|
||||
use file::File;
|
||||
use std::cmp::lexical_ordering;
|
||||
use column::{Column, Permissions, FileName, FileSize, User, Group, HardLinks, Inode};
|
||||
use column::{Column, Permissions, FileName, FileSize, User, Group, HardLinks, Inode, Blocks};
|
||||
use unix::get_current_user_id;
|
||||
use std::ascii::StrAsciiExt;
|
||||
|
||||
|
@ -39,6 +39,7 @@ impl Options {
|
|||
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"),
|
||||
getopts::optflag("S", "blocks", "show number of file system blocks"),
|
||||
];
|
||||
|
||||
match getopts::getopts(args.tail(), opts) {
|
||||
|
@ -67,6 +68,11 @@ impl Options {
|
|||
}
|
||||
|
||||
columns.push(FileSize(matches.opt_present("binary")));
|
||||
|
||||
if matches.opt_present("blocks") {
|
||||
columns.push(Blocks);
|
||||
}
|
||||
|
||||
columns.push(User(get_current_user_id()));
|
||||
|
||||
if matches.opt_present("group") {
|
||||
|
|
Loading…
Reference in New Issue
Block a user