Skip to content

Commit

Permalink
Add colors to the prompt
Browse files Browse the repository at this point in the history
It works, but on Windows the cursor starts at the wrong column.
  • Loading branch information
certik committed Sep 8, 2024
1 parent f59bcb5 commit 3014161
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions crates/shell/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,13 @@ async fn interactive() -> anyhow::Result<()> {

let prompt = cwd
.strip_prefix(home_str)
.map(|stripped| format!("~{}{git_branch}$ ", stripped.replace('\\', "/")))
.unwrap_or_else(|| format!("{}{git_branch}$ ", cwd));
.map(|stripped| {
format!(
"\x1b[34m~{}\x1b[31m{git_branch}\x1b[0m$ ",
stripped.replace('\\', "/")
)
})
.unwrap_or_else(|| format!("\x1b[34m{}\x1b[31m{git_branch}\x1b[0m$ ", cwd));
rl.readline(&prompt)
};

Expand Down

0 comments on commit 3014161

Please sign in to comment.