Fixed a bug(panic), removed useless stuff
This commit is contained in:
parent
b0144c5d07
commit
b2c4dd008f
35
src/main.rs
35
src/main.rs
@ -1,9 +1,9 @@
|
|||||||
use std::env::current_dir as current_dir;
|
use std::env::current_dir;
|
||||||
use std::env::var_os as var_os;
|
use std::env::var_os;
|
||||||
use std::env::args as args;
|
use std::env::args;
|
||||||
use colored::Colorize;
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::ffi::OsString;
|
//use std::ffi::OsString;
|
||||||
|
use colored::Colorize;
|
||||||
|
|
||||||
fn get_shell_char (shell: String) -> String {
|
fn get_shell_char (shell: String) -> String {
|
||||||
let shell_char = match shell.as_str() {
|
let shell_char = match shell.as_str() {
|
||||||
@ -39,39 +39,34 @@ fn abrev_path (pwd: PathBuf, homedir: String) -> String {
|
|||||||
|
|
||||||
for p in &parts[0..len] {
|
for p in &parts[0..len] {
|
||||||
let part = p;
|
let part = p;
|
||||||
fch = part.chars().next().expect("REASON").to_string(); //1st char of p
|
if part.to_string() != "" { // to avoid "/"
|
||||||
short_dir = short_dir.replace(part, &fch);
|
fch = part.chars().next().expect(p).to_string(); //1st char of p
|
||||||
|
short_dir = short_dir.replace(part, &fch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
short_dir
|
short_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
fn root_user (user: Option<OsString>) -> bool {
|
|
||||||
let u = user.expect("UnknownUser").to_str().expect("UnknownUser").to_string();
|
|
||||||
if u == "root"
|
|
||||||
{ true }
|
|
||||||
else
|
|
||||||
{ false }
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() -> std::io::Result<()> {
|
fn main() -> std::io::Result<()> {
|
||||||
let angle = "❯";
|
let angle = "❯";
|
||||||
let pwd = current_dir()?;
|
let pwd = current_dir()?;
|
||||||
let args: Vec<String> = args().collect();
|
let args: Vec<String> = args().collect();
|
||||||
let shell: String;
|
let shell: String;
|
||||||
let user = var_os("USER"); //.expect("UnknownUser").to_str().expect("UnknownUser").to_string();
|
let _user = var_os("USER").expect("UnknownUser").to_str().expect("UnknownUser").to_string();
|
||||||
//let user = var_os("USER").expect("UnknownUser").to_str().expect("UnknownUser").to_string();
|
|
||||||
let homedir = var_os("HOME").expect("UnknownDir").to_str().expect("UnknownDir").to_string();
|
let homedir = var_os("HOME").expect("UnknownDir").to_str().expect("UnknownDir").to_string();
|
||||||
|
|
||||||
|
|
||||||
if args.len() > 1 {
|
if args.len() > 1 {
|
||||||
shell = args[1].clone();
|
shell = args[1].clone();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
shell = "none".to_string();
|
shell = "none".to_string();
|
||||||
}
|
}
|
||||||
//if root_user(user) {
|
/*
|
||||||
// println!("heh");
|
if user == "root" {
|
||||||
//}
|
println!("heh");
|
||||||
|
}*/
|
||||||
|
|
||||||
print!("{} {}{} ",
|
print!("{} {}{} ",
|
||||||
get_shell_char(shell).truecolor(75,75,75),
|
get_shell_char(shell).truecolor(75,75,75),
|
||||||
|
Loading…
Reference in New Issue
Block a user