~kmaasrud/prompt

9b8e223e7d5da4ba7378048230f2f319f3fc6a5d — kmaasrud 1 year, 5 months ago df89bcb
make icon red on non-successful previous command
1 files changed, 13 insertions(+), 1 deletions(-)

M src/icon.rs
M src/icon.rs => src/icon.rs +13 -1
@@ 1,5 1,17 @@
use std::io::{Error, Write};

use crate::color;

pub fn icon<W: Write>(mut w: W) -> Result<(), Error> {
    write!(w, "❯ ")
    match std::env::args()
        .nth(1)
        .and_then(|s| s.parse::<usize>().ok())
    {
        Some(exit_code) if exit_code != 0 => {
            color::red(&mut w)?;
            write!(w, "❯ ")?;
            color::reset(&mut w)
        }
        _ => write!(w, "❯ "),
    }
}