Skip to content

Commit c947608

Browse files
committed
ls: enable ANSI support on Windows for --hyperlink
1 parent de0a19d commit c947608

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

Cargo.lock

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

src/uu/ls/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ once_cell = { workspace = true }
3333
selinux = { workspace = true, optional = true }
3434
hostname = "0.3"
3535

36+
[target.'cfg(windows)'.dependencies]
37+
nu-ansi-term = "0.49.0"
38+
3639
[[bin]]
3740
name = "ls"
3841
path = "src/main.rs"

src/uu/ls/src/ls.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2996,6 +2996,9 @@ fn display_file_name(
29962996
let mut width = name.width();
29972997

29982998
if config.hyperlink {
2999+
#[cfg(windows)]
3000+
let _enabled = nu_ansi_term::enable_ansi_support();
3001+
29993002
let hostname = hostname::get().unwrap_or(OsString::from(""));
30003003
let hostname = hostname.to_string_lossy();
30013004

tests/by-util/test_ls.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3840,6 +3840,7 @@ fn test_ls_hyperlink() {
38403840
let path = at.root_dir_resolved();
38413841

38423842
let result = scene.ucmd().arg("--hyperlink").succeeds();
3843+
println!("stdout: {}", result.stdout_str());
38433844
assert!(result.stdout_str().contains("\x1b]8;;file://"));
38443845
assert!(result
38453846
.stdout_str()

0 commit comments

Comments
 (0)