sort out modules
This commit is contained in:
parent
d1fecadb51
commit
4f90edceef
17
src/indicators/error.rs
Normal file
17
src/indicators/error.rs
Normal file
@ -0,0 +1,17 @@
|
||||
use colored::{ColoredString, Colorize};
|
||||
|
||||
pub fn err(args: Vec<String>) -> String {
|
||||
if args.len() > 2 {
|
||||
args[2].clone() // Error status
|
||||
} else {
|
||||
"none".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn err_indicator(err: String) -> ColoredString {
|
||||
let angle = "❯";
|
||||
match err.as_str() {
|
||||
"0" => angle.truecolor(0, 255, 180),
|
||||
_ => angle.truecolor(255, 53, 94),
|
||||
}
|
||||
}
|
20
src/indicators/shell.rs
Normal file
20
src/indicators/shell.rs
Normal file
@ -0,0 +1,20 @@
|
||||
pub fn get_shell_char(shell: &str) -> String {
|
||||
let shell_char = match shell {
|
||||
"bash" | "/bin/bash" | "/usr/bin/bash" | "-bash" => " ",
|
||||
"zsh" | "/bin/zsh" | "/usr/bin/zsh" | "-zsh" => " ",
|
||||
"fish" => " ",
|
||||
"nushell" => " ",
|
||||
"ion" => " ",
|
||||
"oursh" => " ",
|
||||
_ => " ",
|
||||
};
|
||||
shell_char.to_string()
|
||||
}
|
||||
|
||||
pub fn shell(args: Vec<String>) -> String {
|
||||
if args.len() > 1 {
|
||||
args[1].clone() // Shell symbol
|
||||
} else {
|
||||
"none".to_string()
|
||||
}
|
||||
}
|
47
src/main.rs
47
src/main.rs
@ -1,24 +1,15 @@
|
||||
use colored::{ColoredString, Colorize};
|
||||
//use colored::{ColoredString, Colorize};
|
||||
use colored::Colorize;
|
||||
use std::env::{args, current_dir, var_os};
|
||||
mod git;
|
||||
mod ssh;
|
||||
mod user;
|
||||
use crate::git::*;
|
||||
use crate::ssh::*;
|
||||
use crate::user::*;
|
||||
|
||||
fn get_shell_char(shell: &str) -> String {
|
||||
let shell_char = match shell {
|
||||
"bash" | "/bin/bash" | "/usr/bin/bash" | "-bash" => " ",
|
||||
"zsh" | "/bin/zsh" | "/usr/bin/zsh" | "-zsh" => " ",
|
||||
"fish" => " ",
|
||||
"nushell" => " ",
|
||||
"ion" => " ",
|
||||
"oursh" => " ",
|
||||
_ => " ",
|
||||
};
|
||||
shell_char.to_string()
|
||||
mod indicators {
|
||||
pub mod error;
|
||||
pub mod git;
|
||||
pub mod shell;
|
||||
pub mod ssh;
|
||||
pub mod user;
|
||||
}
|
||||
use crate::indicators::{error::*, git::*, shell::*, ssh::*, user::*};
|
||||
|
||||
fn abrev_path(path: &str) -> String {
|
||||
let mut short_dir = path.to_string();
|
||||
@ -42,27 +33,15 @@ fn abrev_path(path: &str) -> String {
|
||||
}
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
let angle = "❯";
|
||||
|
||||
let mut err: String = String::new();
|
||||
//let angle = "❯";
|
||||
|
||||
let args: Vec<String> = args().collect();
|
||||
let shell: String;
|
||||
if args.len() > 1 {
|
||||
shell = args[1].clone(); // Shell symbol
|
||||
if args.len() > 2 {
|
||||
err.clone_from(&args[2]); // Error status
|
||||
}
|
||||
} else {
|
||||
shell = "none".to_string();
|
||||
}
|
||||
let shell: String = shell(args.clone());
|
||||
|
||||
let root_indicator = root_indicator();
|
||||
|
||||
let err_indicator = match err.as_str() {
|
||||
"0" => angle.truecolor(0, 255, 180),
|
||||
_ => angle.truecolor(255, 53, 94),
|
||||
};
|
||||
let err: String = err(args.clone());
|
||||
let err_indicator = err_indicator(err);
|
||||
|
||||
// SSH status
|
||||
let ssh_char = ssh_char();
|
||||
|
Loading…
Reference in New Issue
Block a user