mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix: make environment detection work on WSL 2 (#3587)
This commit is contained in:
parent
97d0c6bb23
commit
ca4cc59413
3 changed files with 52 additions and 51 deletions
|
|
@ -266,20 +266,20 @@ rules = [
|
||||||
[icon]
|
[icon]
|
||||||
globs = []
|
globs = []
|
||||||
dirs = [
|
dirs = [
|
||||||
{ name = ".config", text = "", fg = "blue" },
|
{ name = ".config", text = "", fg = "#ff9800" },
|
||||||
{ name = ".git", text = "", fg = "blue" },
|
{ name = ".git", text = "", fg = "#00bcd4" },
|
||||||
{ name = ".github", text = "", fg = "blue" },
|
{ name = ".github", text = "", fg = "#03a9f4" },
|
||||||
{ name = ".npm", text = "", fg = "blue" },
|
{ name = ".npm", text = "", fg = "#03a9f4" },
|
||||||
{ name = "Desktop", text = "", fg = "blue" },
|
{ name = "Desktop", text = "", fg = "#00bcd4" },
|
||||||
{ name = "Development", text = "", fg = "blue" },
|
{ name = "Development", text = "", fg = "#00bcd4" },
|
||||||
{ name = "Documents", text = "", fg = "blue" },
|
{ name = "Documents", text = "", fg = "#00bcd4" },
|
||||||
{ name = "Downloads", text = "", fg = "blue" },
|
{ name = "Downloads", text = "", fg = "#00bcd4" },
|
||||||
{ name = "Library", text = "", fg = "blue" },
|
{ name = "Library", text = "", fg = "#00bcd4" },
|
||||||
{ name = "Movies", text = "", fg = "blue" },
|
{ name = "Movies", text = "", fg = "#00bcd4" },
|
||||||
{ name = "Music", text = "", fg = "blue" },
|
{ name = "Music", text = "", fg = "#00bcd4" },
|
||||||
{ name = "Pictures", text = "", fg = "blue" },
|
{ name = "Pictures", text = "", fg = "#00bcd4" },
|
||||||
{ name = "Public", text = "", fg = "blue" },
|
{ name = "Public", text = "", fg = "#00bcd4" },
|
||||||
{ name = "Videos", text = "", fg = "blue" },
|
{ name = "Videos", text = "", fg = "#00bcd4" },
|
||||||
]
|
]
|
||||||
files = [
|
files = [
|
||||||
{ name = ".babelrc", text = "", fg = "#cbcb41" },
|
{ name = ".babelrc", text = "", fg = "#cbcb41" },
|
||||||
|
|
@ -986,19 +986,19 @@ exts = [
|
||||||
]
|
]
|
||||||
conds = [
|
conds = [
|
||||||
# Special files
|
# Special files
|
||||||
{ if = "orphan", text = "" },
|
{ if = "orphan", text = "", fg = "#ffffff" },
|
||||||
{ if = "link", text = "" },
|
{ if = "link", text = "", fg = "#9e9e9e" },
|
||||||
{ if = "block", text = "" },
|
{ if = "block", text = "", fg = "#cddc39" },
|
||||||
{ if = "char", text = "" },
|
{ if = "char", text = "", fg = "#cddc39" },
|
||||||
{ if = "fifo", text = "" },
|
{ if = "fifo", text = "", fg = "#cddc39" },
|
||||||
{ if = "sock", text = "" },
|
{ if = "sock", text = "", fg = "#cddc39" },
|
||||||
{ if = "sticky", text = "" },
|
{ if = "sticky", text = "", fg = "#cddc39" },
|
||||||
{ if = "dummy", text = "" },
|
{ if = "dummy", text = "", fg = "#f44336" },
|
||||||
|
|
||||||
# Fallback
|
# Fallback
|
||||||
{ if = "dir", text = "", fg = "blue" },
|
{ if = "dir", text = "", fg = "#03a9f4" },
|
||||||
{ if = "exec", text = "" },
|
{ if = "exec", text = "", fg = "#8bc34a" },
|
||||||
{ if = "!dir", text = "" },
|
{ if = "!dir", text = "", fg = "#ffffff" },
|
||||||
]
|
]
|
||||||
|
|
||||||
# : }}}
|
# : }}}
|
||||||
|
|
|
||||||
|
|
@ -266,20 +266,20 @@ rules = [
|
||||||
[icon]
|
[icon]
|
||||||
globs = []
|
globs = []
|
||||||
dirs = [
|
dirs = [
|
||||||
{ name = ".config", text = "", fg = "blue" },
|
{ name = ".config", text = "", fg = "#ff9800" },
|
||||||
{ name = ".git", text = "", fg = "blue" },
|
{ name = ".git", text = "", fg = "#009688" },
|
||||||
{ name = ".github", text = "", fg = "blue" },
|
{ name = ".github", text = "", fg = "#03a9f4" },
|
||||||
{ name = ".npm", text = "", fg = "blue" },
|
{ name = ".npm", text = "", fg = "#03a9f4" },
|
||||||
{ name = "Desktop", text = "", fg = "blue" },
|
{ name = "Desktop", text = "", fg = "#009688" },
|
||||||
{ name = "Development", text = "", fg = "blue" },
|
{ name = "Development", text = "", fg = "#009688" },
|
||||||
{ name = "Documents", text = "", fg = "blue" },
|
{ name = "Documents", text = "", fg = "#009688" },
|
||||||
{ name = "Downloads", text = "", fg = "blue" },
|
{ name = "Downloads", text = "", fg = "#009688" },
|
||||||
{ name = "Library", text = "", fg = "blue" },
|
{ name = "Library", text = "", fg = "#009688" },
|
||||||
{ name = "Movies", text = "", fg = "blue" },
|
{ name = "Movies", text = "", fg = "#009688" },
|
||||||
{ name = "Music", text = "", fg = "blue" },
|
{ name = "Music", text = "", fg = "#009688" },
|
||||||
{ name = "Pictures", text = "", fg = "blue" },
|
{ name = "Pictures", text = "", fg = "#009688" },
|
||||||
{ name = "Public", text = "", fg = "blue" },
|
{ name = "Public", text = "", fg = "#009688" },
|
||||||
{ name = "Videos", text = "", fg = "blue" },
|
{ name = "Videos", text = "", fg = "#009688" },
|
||||||
]
|
]
|
||||||
files = [
|
files = [
|
||||||
{ name = ".babelrc", text = "", fg = "#666620" },
|
{ name = ".babelrc", text = "", fg = "#666620" },
|
||||||
|
|
@ -986,19 +986,19 @@ exts = [
|
||||||
]
|
]
|
||||||
conds = [
|
conds = [
|
||||||
# Special files
|
# Special files
|
||||||
{ if = "orphan", text = "" },
|
{ if = "orphan", text = "", fg = "#000000" },
|
||||||
{ if = "link", text = "" },
|
{ if = "link", text = "", fg = "#9e9e9e" },
|
||||||
{ if = "block", text = "" },
|
{ if = "block", text = "", fg = "#ffc107" },
|
||||||
{ if = "char", text = "" },
|
{ if = "char", text = "", fg = "#ffc107" },
|
||||||
{ if = "fifo", text = "" },
|
{ if = "fifo", text = "", fg = "#ffc107" },
|
||||||
{ if = "sock", text = "" },
|
{ if = "sock", text = "", fg = "#ffc107" },
|
||||||
{ if = "sticky", text = "" },
|
{ if = "sticky", text = "", fg = "#ffc107" },
|
||||||
{ if = "dummy", text = "" },
|
{ if = "dummy", text = "", fg = "#f44336" },
|
||||||
|
|
||||||
# Fallback
|
# Fallback
|
||||||
{ if = "dir", text = "", fg = "blue" },
|
{ if = "dir", text = "", fg = "#03a9f4" },
|
||||||
{ if = "exec", text = "" },
|
{ if = "exec", text = "", fg = "#8bc34a" },
|
||||||
{ if = "!dir", text = "" },
|
{ if = "!dir", text = "", fg = "#000000" },
|
||||||
]
|
]
|
||||||
|
|
||||||
# : }}}
|
# : }}}
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
pub fn in_wsl() -> bool {
|
||||||
#[cfg(target_os = "linux")]
|
#[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"))]
|
#[cfg(not(target_os = "linux"))]
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue