Skip to content

Commit

Permalink
fix "needed single revision" error in prompt (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
amtoine authored Dec 6, 2024
1 parent 2cc0ee1 commit 313f0a6
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export def get-left-prompt [duration_threshold: duration]: nothing -> string {
| get stdout
| is-empty
)
let is_uninitialized = do -i { ^git rev-parse --short HEAD }
| complete
| get stderr
| $in =~ "Needed a single revision"

# FIXME: use `path sanitize` from `nu-git-manager`
let pwd = pwd | str replace --regex '^.:' '' | str replace --all '\' '/'
Expand All @@ -33,7 +37,9 @@ export def get-left-prompt [duration_threshold: duration]: nothing -> string {
$pwd | simplify-path | color "green"
}

let git_branch_segment = if $is_git_repo {
let git_branch_segment = if $is_uninitialized {
$"\((ansi red)no rev(ansi reset)\)"
} else if $is_git_repo {
let revision = get-revision --short-hash
let pretty_branch_tokens = match $revision.type {
"branch" => [
Expand Down

0 comments on commit 313f0a6

Please sign in to comment.