From ca4cc594136e313b47f8da0f3699b7ea9699a959 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Mon, 19 Jan 2026 01:08:15 +0800 Subject: [PATCH] fix: make environment detection work on WSL 2 (#3587) --- yazi-config/preset/theme-dark.toml | 50 ++++++++++++++--------------- yazi-config/preset/theme-light.toml | 50 ++++++++++++++--------------- yazi-shared/src/env.rs | 3 +- 3 files changed, 52 insertions(+), 51 deletions(-) diff --git a/yazi-config/preset/theme-dark.toml b/yazi-config/preset/theme-dark.toml index ede9cc34..d8b4365d 100644 --- a/yazi-config/preset/theme-dark.toml +++ b/yazi-config/preset/theme-dark.toml @@ -266,20 +266,20 @@ rules = [ [icon] globs = [] dirs = [ - { name = ".config", text = "", fg = "blue" }, - { name = ".git", text = "", fg = "blue" }, - { name = ".github", text = "", fg = "blue" }, - { name = ".npm", text = "", fg = "blue" }, - { name = "Desktop", text = "", fg = "blue" }, - { name = "Development", text = "", fg = "blue" }, - { name = "Documents", text = "", fg = "blue" }, - { name = "Downloads", text = "", fg = "blue" }, - { name = "Library", text = "", fg = "blue" }, - { name = "Movies", text = "", fg = "blue" }, - { name = "Music", text = "", fg = "blue" }, - { name = "Pictures", text = "", fg = "blue" }, - { name = "Public", text = "", fg = "blue" }, - { name = "Videos", text = "", fg = "blue" }, + { name = ".config", text = "", fg = "#ff9800" }, + { name = ".git", text = "", fg = "#00bcd4" }, + { name = ".github", text = "", fg = "#03a9f4" }, + { name = ".npm", text = "", fg = "#03a9f4" }, + { name = "Desktop", text = "", fg = "#00bcd4" }, + { name = "Development", text = "", fg = "#00bcd4" }, + { name = "Documents", text = "", fg = "#00bcd4" }, + { name = "Downloads", text = "", fg = "#00bcd4" }, + { name = "Library", text = "", fg = "#00bcd4" }, + { name = "Movies", text = "", fg = "#00bcd4" }, + { name = "Music", text = "", fg = "#00bcd4" }, + { name = "Pictures", text = "", fg = "#00bcd4" }, + { name = "Public", text = "", fg = "#00bcd4" }, + { name = "Videos", text = "", fg = "#00bcd4" }, ] files = [ { name = ".babelrc", text = "", fg = "#cbcb41" }, @@ -986,19 +986,19 @@ exts = [ ] conds = [ # Special files - { if = "orphan", text = "" }, - { if = "link", text = "" }, - { if = "block", text = "" }, - { if = "char", text = "" }, - { if = "fifo", text = "" }, - { if = "sock", text = "" }, - { if = "sticky", text = "" }, - { if = "dummy", text = "" }, + { if = "orphan", text = "", fg = "#ffffff" }, + { if = "link", text = "", fg = "#9e9e9e" }, + { if = "block", text = "", fg = "#cddc39" }, + { if = "char", text = "", fg = "#cddc39" }, + { if = "fifo", text = "", fg = "#cddc39" }, + { if = "sock", text = "", fg = "#cddc39" }, + { if = "sticky", text = "", fg = "#cddc39" }, + { if = "dummy", text = "", fg = "#f44336" }, # Fallback - { if = "dir", text = "", fg = "blue" }, - { if = "exec", text = "" }, - { if = "!dir", text = "" }, + { if = "dir", text = "", fg = "#03a9f4" }, + { if = "exec", text = "", fg = "#8bc34a" }, + { if = "!dir", text = "", fg = "#ffffff" }, ] # : }}} diff --git a/yazi-config/preset/theme-light.toml b/yazi-config/preset/theme-light.toml index 41b6838f..f23cb85c 100644 --- a/yazi-config/preset/theme-light.toml +++ b/yazi-config/preset/theme-light.toml @@ -266,20 +266,20 @@ rules = [ [icon] globs = [] dirs = [ - { name = ".config", text = "", fg = "blue" }, - { name = ".git", text = "", fg = "blue" }, - { name = ".github", text = "", fg = "blue" }, - { name = ".npm", text = "", fg = "blue" }, - { name = "Desktop", text = "", fg = "blue" }, - { name = "Development", text = "", fg = "blue" }, - { name = "Documents", text = "", fg = "blue" }, - { name = "Downloads", text = "", fg = "blue" }, - { name = "Library", text = "", fg = "blue" }, - { name = "Movies", text = "", fg = "blue" }, - { name = "Music", text = "", fg = "blue" }, - { name = "Pictures", text = "", fg = "blue" }, - { name = "Public", text = "", fg = "blue" }, - { name = "Videos", text = "", fg = "blue" }, + { name = ".config", text = "", fg = "#ff9800" }, + { name = ".git", text = "", fg = "#009688" }, + { name = ".github", text = "", fg = "#03a9f4" }, + { name = ".npm", text = "", fg = "#03a9f4" }, + { name = "Desktop", text = "", fg = "#009688" }, + { name = "Development", text = "", fg = "#009688" }, + { name = "Documents", text = "", fg = "#009688" }, + { name = "Downloads", text = "", fg = "#009688" }, + { name = "Library", text = "", fg = "#009688" }, + { name = "Movies", text = "", fg = "#009688" }, + { name = "Music", text = "", fg = "#009688" }, + { name = "Pictures", text = "", fg = "#009688" }, + { name = "Public", text = "", fg = "#009688" }, + { name = "Videos", text = "", fg = "#009688" }, ] files = [ { name = ".babelrc", text = "", fg = "#666620" }, @@ -986,19 +986,19 @@ exts = [ ] conds = [ # Special files - { if = "orphan", text = "" }, - { if = "link", text = "" }, - { if = "block", text = "" }, - { if = "char", text = "" }, - { if = "fifo", text = "" }, - { if = "sock", text = "" }, - { if = "sticky", text = "" }, - { if = "dummy", text = "" }, + { if = "orphan", text = "", fg = "#000000" }, + { if = "link", text = "", fg = "#9e9e9e" }, + { if = "block", text = "", fg = "#ffc107" }, + { if = "char", text = "", fg = "#ffc107" }, + { if = "fifo", text = "", fg = "#ffc107" }, + { if = "sock", text = "", fg = "#ffc107" }, + { if = "sticky", text = "", fg = "#ffc107" }, + { if = "dummy", text = "", fg = "#f44336" }, # Fallback - { if = "dir", text = "", fg = "blue" }, - { if = "exec", text = "" }, - { if = "!dir", text = "" }, + { if = "dir", text = "", fg = "#03a9f4" }, + { if = "exec", text = "", fg = "#8bc34a" }, + { if = "!dir", text = "", fg = "#000000" }, ] # : }}} diff --git a/yazi-shared/src/env.rs b/yazi-shared/src/env.rs index bc6a9c2c..4dbd5644 100644 --- a/yazi-shared/src/env.rs +++ b/yazi-shared/src/env.rs @@ -9,7 +9,8 @@ pub fn env_exists(name: &str) -> bool { std::env::var_os(name).is_some_and(|s| ! pub fn in_wsl() -> bool { #[cfg(target_os = "linux")] { - std::fs::symlink_metadata("/proc/sys/fs/binfmt_misc/WSLInterop").is_ok() + std::fs::read("/proc/sys/kernel/osrelease") + .is_ok_and(|b| b.windows(11).any(|w| w == b"-microsoft-")) } #[cfg(not(target_os = "linux"))] {