1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-11-16 10:05:13 +00:00
starship/src/modules/char.rs

35 lines
826 B
Rust
Raw Normal View History

2019-04-04 00:14:26 +00:00
use crate::Segment;
use ansi_term::{Color, Style};
use std::env;
pub fn segment() -> Segment {
const PROMPT_CHAR: &str = "";
const COLOR_SUCCESS: Color = Color::Green;
const COLOR_FAILURE: Color = Color::Red;
let default_prefix = Segment {
value: String::from("testPrefix"),
style: Style::default(),
prefix: None,
suffix: None,
};
let color;
if let Ok(status) = env::var("status") {
if status == "0" {
color = COLOR_SUCCESS;
} else {
color = COLOR_FAILURE;
}
} else {
panic!("No status environment variable provided");
}
Segment {
prefix: Some(Box::new(default_prefix)),
value: String::from(PROMPT_CHAR),
style: Style::new().fg(color),
suffix: None,
}
}