feat(custom-commands): add an optional --target-branch flag to cmr command

This commit is contained in:
Oliver
2026-01-04 10:37:16 +01:00
parent 7a61ac5437
commit fd21e245c6
2 changed files with 15 additions and 3 deletions

View File

@@ -26,7 +26,7 @@ _cmr() {
setopt extended_glob
local -a opts
opts=('--draft')
opts=('--draft' '--target-branch')
# Option completion
if [[ $words[CURRENT] == -* ]]; then
@@ -34,6 +34,16 @@ _cmr() {
return
fi
# Check if previous word was --target-branch
local prev_word="${words[CURRENT-1]}"
if [[ "$prev_word" == "--target-branch" ]]; then
# Complete with git branches
local -a branches
branches=(${(f)"$(git branch -a 2>/dev/null | sed 's/^[* ]*//' | sed 's/^remotes\/origin\///' | sort -u)"})
_describe 'branches' branches
return
fi
# Cache path
: ${CMR_USER_CACHE:="$HOME/.cache/cmr_users"}