M src/cwd.rs => src/cwd.rs +3 -2
@@ 1,10 1,11 @@
+use std::env::{current_dir, var_os};
use std::io::{Error, Write};
use std::path::Path;
pub fn cwd<W: Write>(mut w: W) -> Result<(), Error> {
- if let Ok(mut cwd) = std::env::current_dir() {
+ if let Ok(mut cwd) = current_dir() {
cwd = cwd.canonicalize()?;
- if let Some(home) = std::env::var_os("HOME") {
+ if let Some(home) = var_os("HOME") {
if let Ok(stripped) = cwd.strip_prefix(home) {
cwd = Path::new("~").join(stripped);
}
M src/main.rs => src/main.rs +10 -7
@@ 3,17 3,20 @@
mod cwd;
mod git;
mod icon;
+#[cfg(target_family = "unix")]
mod nix;
-use std::io::BufWriter;
-use std::io::{Error, Write};
+use std::io::{stdout, BufWriter, Error, Write};
fn main() -> Result<(), Error> {
- let mut stdout = BufWriter::new(std::io::stdout().lock());
-
- faint(&mut stdout)?;
- nix::nix(&mut stdout)?;
- reset(&mut stdout)?;
+ let mut stdout = BufWriter::new(stdout().lock());
+
+ #[cfg(target_family = "unix")]
+ {
+ faint(&mut stdout)?;
+ nix::nix(&mut stdout)?;
+ reset(&mut stdout)?;
+ }
cwd::cwd(&mut stdout)?;