Skip to content

Commit

Permalink
feat: add bash shell completions
Browse files Browse the repository at this point in the history
  • Loading branch information
suft committed Dec 1, 2024
1 parent 36fd505 commit bcdd3a1
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions completions/git-forgit.bash
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ _git_stash_show()
__gitcomp_nl "$(__git stash list | sed -n -e 's/:.*//p')"
}

_git_worktrees()
{
__gitcomp_nl "$(git worktree list --porcelain | awk '/worktree/ {print $2}')"
}

# Completion for git-forgit
# This includes git aliases, e.g. "alias.cb=forgit checkout_branch" will
# correctly complete available branches on "git cb".
Expand Down Expand Up @@ -77,6 +82,10 @@ _git_forgit()
revert_commit
stash_show
stash_push
worktree_select
worktree_lock
worktree_remove
worktree_unlock
"

case ${cword} in
Expand All @@ -102,6 +111,10 @@ _git_forgit()
reset_head) _git_reset ;;
revert_commit) _git_revert ;;
stash_show) _git_stash_show ;;
worktree_select) _git_worktrees ;;
worktree_lock) _git_worktrees ;;
worktree_remove) _git_worktrees ;;
worktree_unlock) _git_worktrees ;;
esac
;;
*)
Expand Down Expand Up @@ -136,6 +149,10 @@ then
__git_complete forgit::reset::head _git_reset
__git_complete forgit::revert::commit _git_revert
__git_complete forgit::stash::show _git_stash_show
__git_complete forgit::worktree::select _git_worktrees
__git_complete forgit::worktree::lock _git_worktrees
__git_complete forgit::worktree::remove _git_worktrees
__git_complete forgit::worktree::unlock _git_worktrees

# Completion for forgit plugin shell aliases
if [[ -z "$FORGIT_NO_ALIASES" ]]; then
Expand All @@ -155,5 +172,9 @@ then
__git_complete "${forgit_reset_head}" _git_reset
__git_complete "${forgit_revert_commit}" _git_revert
__git_complete "${forgit_stash_show}" _git_stash_show
__git_complete "${forgit_worktree_select}" _git_worktrees
__git_complete "${forgit_worktree_lock}" _git_worktrees
__git_complete "${forgit_worktree_remove}" _git_worktrees
__git_complete "${forgit_worktree_unlock}" _git_worktrees
fi
fi

0 comments on commit bcdd3a1

Please sign in to comment.