Skip to content

Commit

Permalink
feat: hide specified files and dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
TobisLee committed Dec 23, 2024
1 parent 5bd71bf commit 2fdd7b6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
25 changes: 13 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions yazi-config/src/manager/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub struct Manager {
pub scrolloff: u8,
pub mouse_events: MouseEvents,
pub title_format: String,
pub hidden_rule: String,

// TODO: remove this in Yazi 0.4.2
#[serde(default)]
Expand Down
2 changes: 2 additions & 0 deletions yazi-shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ rust-version = "1.78.0"

[dependencies]
yazi-macro = { path = "../yazi-macro", version = "0.4.3" }
yazi-config = { path = "../yazi-config", version = "0.4.3" }

# External dependencies
anyhow = { workspace = true }
Expand All @@ -22,6 +23,7 @@ ratatui = { workspace = true }
serde = { workspace = true }
shell-words = { workspace = true }
tokio = { workspace = true }
regex = { workspace = true }

[target."cfg(unix)".dependencies]
libc = { workspace = true }
Expand Down
7 changes: 6 additions & 1 deletion yazi-shared/src/url/urn.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::{borrow::{Borrow, Cow}, ffi::OsStr, ops::Deref, path::{Path, PathBuf}};
use regex::Regex;

use yazi_config::MANAGER;

#[derive(Debug, Eq, PartialEq, Hash)]
#[repr(transparent)]
Expand All @@ -16,7 +19,9 @@ impl Urn {
#[cfg(unix)]
#[inline]
pub fn is_hidden(&self) -> bool {
self.name().is_some_and(|s| s.as_encoded_bytes().starts_with(b"."))
// let re = Regex::new(r"^\.|^lost\+found$").unwrap();
let re = Regex::new(MANAGER.hidden_rule).unwrap();
self.name().is_some_and(|s| re.is_match(&String::from_utf8_lossy(s.as_encoded_bytes())))
}
}

Expand Down

0 comments on commit 2fdd7b6

Please sign in to comment.