A src/color.rs => src/color.rs +13 -0
@@ 0,0 1,13 @@
+use std::io::{Error, Write};
+
+pub fn faint<W: Write>(mut w: W) -> Result<(), Error> {
+ write!(w, "\x1b[2m")
+}
+
+pub fn reset<W: Write>(mut w: W) -> Result<(), Error> {
+ write!(w, "\x1b[0m")
+}
+
+pub fn red<W: Write>(mut w: W) -> Result<(), Error> {
+ write!(w, "\x1b[31m")
+}
M src/main.rs => src/main.rs +5 -12
@@ 1,5 1,6 @@
#![feature(byte_slice_trim_ascii)]
+mod color;
mod cwd;
mod git;
mod icon;
@@ 13,26 14,18 @@ fn main() -> Result<(), Error> {
#[cfg(target_family = "unix")]
{
- faint(&mut stdout)?;
+ color::faint(&mut stdout)?;
nix::nix(&mut stdout)?;
- reset(&mut stdout)?;
+ color::reset(&mut stdout)?;
}
cwd::cwd(&mut stdout)?;
- faint(&mut stdout)?;
+ color::faint(&mut stdout)?;
git::git(&mut stdout)?;
- reset(&mut stdout)?;
+ color::reset(&mut stdout)?;
icon::icon(&mut stdout)?;
stdout.flush()
}
-
-fn faint<W: Write>(mut w: W) -> Result<(), Error> {
- write!(w, "\x1b[2m")
-}
-
-fn reset<W: Write>(mut w: W) -> Result<(), Error> {
- write!(w, "\x1b[0m")
-}