feed
This commit is contained in:
44
src/main.rs
Normal file
44
src/main.rs
Normal file
@@ -0,0 +1,44 @@
|
||||
use std::{path::PathBuf, string};
|
||||
|
||||
fn main() -> eyre::Result<()> {
|
||||
// Choose dir
|
||||
let root_dir = "/home/kjuulh/git/";
|
||||
|
||||
let mut projects: Vec<PathBuf> = vec![];
|
||||
|
||||
let pattern = regex::Regex::new(".*\\.git$")?;
|
||||
|
||||
// Look for dir .git if found add path to map
|
||||
for entry in walkdir::WalkDir::new(root_dir)
|
||||
.follow_links(true)
|
||||
.into_iter()
|
||||
.filter_map(|e| e.ok())
|
||||
{
|
||||
let metadata = entry.metadata()?;
|
||||
if metadata.is_dir() {
|
||||
let name = entry.file_name().to_string_lossy();
|
||||
if pattern.is_match(&name) {
|
||||
projects.push(entry.into_path())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Print
|
||||
println!("writing projects");
|
||||
let projects_str = projects
|
||||
.into_iter()
|
||||
.map(|mut p| {
|
||||
p.pop();
|
||||
p
|
||||
})
|
||||
.map(|p| p.to_string_lossy().to_string())
|
||||
.collect::<Vec<String>>();
|
||||
|
||||
let content = projects_str.join("\n");
|
||||
std::fs::write(
|
||||
"/home/kjuulh/.local/share/nvim/project_nvim/project_history",
|
||||
content,
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
Reference in New Issue
Block a user