Skip to content

Commit b9e7504

Browse files
committed
symlinks now actually show the desination or origin when they sometimes wouldn't
1 parent 5432601 commit b9e7504

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "natls"
3-
version = "2.1.3"
3+
version = "2.1.4"
44
authors = ["Will Lane <[email protected]>"]
55
description = "nat - the 'ls' replacement you never knew you needed"
66
license = "MIT"

snapcraft.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: natls
2-
version: '2.1.3'
2+
version: '2.1.4'
33
summary: the 'ls' replacement you never knew you needed
44
description: |
55
Nat is a complete replacement for the 'ls' command

src/main.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,7 @@ impl PathType {
129129
Self::Symlink => text_effects::italic(&format!(
130130
"{} -> {}",
131131
name,
132-
std::fs::canonicalize(std::fs::read_link(file).unwrap())
133-
.unwrap_or(file.to_path_buf())
134-
.to_str()
135-
.unwrap_or(name)
132+
std::fs::read_link(file).unwrap().display().to_string()
136133
)),
137134
Self::Path => text_effects::bold(name),
138135
Self::Pipe => text_effects::bold(&format!(
@@ -422,7 +419,7 @@ impl std::fmt::Display for File {
422419
res = format!(
423420
"{}{}",
424421
v.get_color_for_type(),
425-
v.get_text_traits_for_type(self.path.file_name().unwrap().to_str().unwrap(), &self.path)
422+
v.get_text_traits_for_type(&self.path.components().next_back().unwrap().as_os_str().to_string_lossy().to_string(), &self.path)
426423
);
427424
} else {
428425
res = format!(
@@ -442,7 +439,7 @@ impl std::fmt::Debug for File {
442439
for (i, v) in self.file_type.iter().enumerate() {
443440
if i == 0 {
444441
res =
445-
v.get_text_traits_for_type(self.path.file_name().unwrap().to_str().unwrap(), &self.path);
442+
v.get_text_traits_for_type(&self.path.components().next_back().unwrap().as_os_str().to_string_lossy().to_string(), &self.path);
446443
res = format!("{}{}", v.get_color_for_type(), res);
447444
} else {
448445
res = v.get_text_traits_for_type(&res, &self.path);

0 commit comments

Comments
 (0)