Symlinks now show the target they are pointing to
This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
# lsplus
|
# lsplus
|
||||||
A better ls for linux systems, writter in rust
|
A better ls for linux systems, written in rust
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
use std::{fmt::Display, fs, os::unix::prelude::FileTypeExt, path::Path, time::SystemTime};
|
use std::{
|
||||||
|
fmt::Display,
|
||||||
|
fs::{self, read_link},
|
||||||
|
os::unix::prelude::FileTypeExt,
|
||||||
|
path::Path,
|
||||||
|
time::SystemTime,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::utils::get_icon_file_type;
|
use crate::utils::get_icon_file_type;
|
||||||
|
|
||||||
@@ -44,15 +50,22 @@ impl Element {
|
|||||||
t = TypeOfFile::File;
|
t = TypeOfFile::File;
|
||||||
}
|
}
|
||||||
|
|
||||||
Self {
|
let mut name = path_built
|
||||||
path: path_str.to_string(),
|
|
||||||
file_type: t,
|
|
||||||
name: path_built
|
|
||||||
.file_name()
|
.file_name()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_string(),
|
.to_string();
|
||||||
|
|
||||||
|
if symlink_metadata.is_symlink() {
|
||||||
|
name.push_str(" -> ");
|
||||||
|
name.push_str(read_link(path_built).unwrap().to_str().unwrap())
|
||||||
|
}
|
||||||
|
|
||||||
|
Self {
|
||||||
|
path: path_str.to_string(),
|
||||||
|
file_type: t,
|
||||||
|
name,
|
||||||
perms: metadata.permissions(),
|
perms: metadata.permissions(),
|
||||||
size: metadata.len(),
|
size: metadata.len(),
|
||||||
creation: metadata.created().unwrap(),
|
creation: metadata.created().unwrap(),
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ pub fn list(mut elements: Vec<Element>) {
|
|||||||
elements.sort_unstable_by_key(|a: &Element| a.get_name());
|
elements.sort_unstable_by_key(|a: &Element| a.get_name());
|
||||||
let width = term_size::dimensions().unwrap().0;
|
let width = term_size::dimensions().unwrap().0;
|
||||||
// ╭──────────────╼ File name ╾──────────────┬─╼ Size ╾─┬──╼ Creation ╾──╮
|
// ╭──────────────╼ File name ╾──────────────┬─╼ Size ╾─┬──╼ Creation ╾──╮
|
||||||
// │ │ │ │
|
// │ some_example_file │ 420.69 G │ 01-01-70 00:00 │
|
||||||
// ╰─────────────────────────────────────────┴──────────┴────────────────╯
|
// ╰─────────────────────────────────────────┴──────────┴────────────────╯
|
||||||
let mut name_max_len = 0;
|
let mut name_max_len = 0;
|
||||||
for e in &elements {
|
for e in &elements {
|
||||||
|
|||||||
Reference in New Issue
Block a user