Skip to content

Instantly share code, notes, and snippets.

@aelloc
Created March 31, 2023 13:35
Show Gist options
  • Select an option

  • Save aelloc/353445f5e32b7ee211086dbe5433c23b to your computer and use it in GitHub Desktop.

Select an option

Save aelloc/353445f5e32b7ee211086dbe5433c23b to your computer and use it in GitHub Desktop.
use std::{
env,
fs::{self, File},
path::Path,
};
pub fn config() {
let config_path = format!(
"/home/{}/.xonfig/",
env::var("LOGNAME").unwrap_or(".config".to_owned())
);
let file_path = format!(
"/home/{}/.xonfig/.xonfig",
env::var("LOGNAME").unwrap_or(".xonfig".to_owned())
);
println!("{}", config_path);
if !Path::new(&file_path).exists() {
fs::create_dir(config_path);
File::create(file_path).unwrap();
}
}
fn main() {
config();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment