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};
|
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 {
|
mod indicators {
|
||||||
let shell_char = match shell {
|
pub mod error;
|
||||||
"bash" | "/bin/bash" | "/usr/bin/bash" | "-bash" => " ",
|
pub mod git;
|
||||||
"zsh" | "/bin/zsh" | "/usr/bin/zsh" | "-zsh" => " ",
|
pub mod shell;
|
||||||
"fish" => " ",
|
pub mod ssh;
|
||||||
"nushell" => " ",
|
pub mod user;
|
||||||
"ion" => " ",
|
|
||||||
"oursh" => " ",
|
|
||||||
_ => " ",
|
|
||||||
};
|
|
||||||
shell_char.to_string()
|
|
||||||
}
|
}
|
||||||
|
use crate::indicators::{error::*, git::*, shell::*, ssh::*, user::*};
|
||||||
|
|
||||||
fn abrev_path(path: &str) -> String {
|
fn abrev_path(path: &str) -> String {
|
||||||
let mut short_dir = path.to_string();
|
let mut short_dir = path.to_string();
|
||||||
@ -42,27 +33,15 @@ fn abrev_path(path: &str) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> std::io::Result<()> {
|
fn main() -> std::io::Result<()> {
|
||||||
let angle = "❯";
|
//let angle = "❯";
|
||||||
|
|
||||||
let mut err: String = String::new();
|
|
||||||
|
|
||||||
let args: Vec<String> = args().collect();
|
let args: Vec<String> = args().collect();
|
||||||
let shell: String;
|
let shell: String = shell(args.clone());
|
||||||
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 root_indicator = root_indicator();
|
let root_indicator = root_indicator();
|
||||||
|
|
||||||
let err_indicator = match err.as_str() {
|
let err: String = err(args.clone());
|
||||||
"0" => angle.truecolor(0, 255, 180),
|
let err_indicator = err_indicator(err);
|
||||||
_ => angle.truecolor(255, 53, 94),
|
|
||||||
};
|
|
||||||
|
|
||||||
// SSH status
|
// SSH status
|
||||||
let ssh_char = ssh_char();
|
let ssh_char = ssh_char();
|
||||||
|
Loading…
Reference in New Issue
Block a user