@@ 1,3 1,32 @@
-fn main() {
- println!("Hello, world!");
+#![feature(byte_slice_trim_ascii)]
+
+use std::io::BufWriter;
+use std::io::Error;
+use std::io::Write;
+use std::path::Path;
+
+fn main() -> Result<(), Error> {
+ let mut stdout = BufWriter::new(std::io::stdout());
+
+ cwd(&mut stdout)?;
+ icon(&mut stdout)?;
+
+ stdout.flush()
+}
+
+fn icon<W: Write>(mut w: W) -> Result<(), Error> {
+ write!(w, "❯ ")
+}
+
+fn cwd<W: Write>(mut w: W) -> Result<(), Error> {
+ if let Ok(mut cwd) = std::env::current_dir() {
+ cwd = cwd.canonicalize()?;
+ if let Some(home) = std::env::var_os("HOME") {
+ if let Ok(stripped) = cwd.strip_prefix(home) {
+ cwd = Path::new("~").join(stripped);
+ }
+ }
+ write!(w, "{} ", cwd.display())?;
+ }
+ Ok(())
}