Update main.rs
This commit is contained in:
parent
aef1690c1b
commit
90fd10f202
1 changed files with 24 additions and 14 deletions
16
src/main.rs
16
src/main.rs
|
@ -59,7 +59,7 @@ fn main() {
|
|||
// I know it's terrible, but it works.
|
||||
let mut kernel = String::new();
|
||||
{
|
||||
let kernel_file = File::open("/proc/version").expect("do u even linux bro???");
|
||||
let kernel_file = File::open("/proc/version").expect("Read the README.md you dumbass");
|
||||
let mut kernel_reader = BufReader::new(kernel_file);
|
||||
kernel_reader.read_line(&mut kernel).expect("Failed string conversion");
|
||||
}
|
||||
|
@ -135,9 +135,19 @@ fn main() {
|
|||
}
|
||||
|
||||
// Get shell
|
||||
let shell = env::var("SHELL").expect("Could not read $SHELL variable");
|
||||
println!("│ Shell: {}", Cyan.paint(shell));
|
||||
let shell_raw = env::var("SHELL").expect("Could not read $SHELL variable");
|
||||
|
||||
// Split the path using '/' as the separator
|
||||
// Thanks ChatGPT
|
||||
let parts: Vec<&str> = shell_raw.rsplitn(2, '/').collect();
|
||||
|
||||
// Check if the path contains at least one '/'
|
||||
if parts.len() > 1 {
|
||||
let shell = parts[0];
|
||||
println!("│ Shell: {}", Cyan.paint(shell));
|
||||
} else {
|
||||
println!("Invalid path format.");
|
||||
}
|
||||
// Time for a challenge, Get CPU model!
|
||||
{
|
||||
let file = File::open("/proc/cpuinfo").expect("Could not read /proc/cpuinfo");
|
||||
|
|
Loading…
Reference in a new issue