Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion etc/bash_completion.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# shellcheck shell=bash
# bash completion support for git-extras.

__gitex_heads_unique() {
local branch specified=("${COMP_WORDS[@]:2}")
for branch in $(__git_heads); do
[[ " ${specified[*]} " == *" $branch "* ]] || printf '%s\n' "$branch"
done
}

_git_authors(){
__gitcomp "-l --list --no-email"
}
Expand Down Expand Up @@ -84,7 +91,7 @@ __git_cp(){
}

_git_delete_branch(){
__gitcomp "$(__git_heads)"
__gitcomp "$(__gitex_heads_unique)"
}

_git_delete_squashed_branches(){
Expand Down
12 changes: 10 additions & 2 deletions etc/git-extras-completion.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ __gitex_branch_names() {
_wanted branch-names expl branch-name compadd $* - $branch_names
}

__gitex_branch_names_unique() {
local expl
declare -a branch_names already_specified
branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/})
__gitex_command_successful || return
already_specified=(${words[2,-1]})
_wanted branch-names expl branch-name compadd -F already_specified $* - $branch_names
}

__gitex_specific_branch_names() {
local expl
declare -a branch_names
Expand Down Expand Up @@ -196,8 +205,7 @@ _git-create-branch() {
}

_git-delete-branch() {
_arguments \
':branch-name:__gitex_branch_names'
__gitex_branch_names_unique
}

_git-delete-squashed-branches() {
Expand Down
Loading