Skip to content

Commit 759218d

Browse files
authored
🐛 fix additional + in git local branches (#1019)
Hi! I realized if you use worktrees, with at least one branch checked out and you: ``` git switch <tab> ``` the autocompletion is wrong, putting a `+ ` before the branch, and piping it into the cmdline. This comes from `nu-complete git local branches` function, it which it only replaces `* ` for the current branch, but it doesn't for `+ ` for worktrees. Here is a sample: ![image](https://github.com/user-attachments/assets/814c728b-82da-4d15-9f22-ff0fd5a92ae1) I tested on my pc and works allright!
1 parent fd686c0 commit 759218d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

custom-completions/git/git-completions.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def "nu-complete git commits current branch" [] {
2424

2525
# Yield local branches like `main`, `feature/typo_fix`
2626
def "nu-complete git local branches" [] {
27-
^git branch --no-color | lines | each { |line| $line | str replace '* ' "" | str trim }
27+
^git branch --no-color | lines | each { |line| $line | str replace '* ' "" | str replace '+ ' "" | str trim }
2828
}
2929

3030
# Yield remote branches like `origin/main`, `upstream/feature-a`

0 commit comments

Comments
 (0)