Skip to content

Commit

Permalink
feat: generate project title for wezterm
Browse files Browse the repository at this point in the history
  • Loading branch information
pbogut committed Jan 18, 2024
1 parent c9d019a commit f8c7cbc
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions wezterm-status/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
enum Status {
Right,
Title,
}

fn main() {
let args: Vec<String> = std::env::args().collect();
let cwd = std::env::current_dir()
Expand All @@ -10,6 +15,14 @@ fn main() {
Some(path) => path,
None => &cwd,
};
let status_type = match args.get(2) {
Some(arg) => match arg.as_str() {
"--right" => Status::Right,
"--title" => Status::Title,
_ => Status::Right,
},
None => Status::Right,
};

let abs_path = cmd_out("git", &["-C", &path, "rev-parse", "--absolute-git-dir"]);
let top_path = cmd_out("git", &["-C", &path, "rev-parse", "--show-toplevel"]);
Expand All @@ -30,10 +43,19 @@ fn main() {
};

let base_name = path.split("/").last().unwrap();
if branch_name != "" {
println!("{}", format!(" {}   {}", base_name, branch_name));
} else {
println!("{}", format!(" {}", base_name));
match status_type {
Status::Right => {
if branch_name != "" {
println!("{}", format!(" {}   {}", base_name, branch_name));
} else {
println!("{}", format!(" {}", base_name));
}
}
Status::Title => {
if branch_name != "" {
println!("{}", format!("{}  {}", base_name, branch_name));
}
}
}
}

Expand Down

0 comments on commit f8c7cbc

Please sign in to comment.