From fd21e245c68d2cc40757246303849c8e6c6a0ce0 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 4 Jan 2026 10:37:16 +0100 Subject: [PATCH] feat(custom-commands): add an optional --target-branch flag to cmr command --- omz-custom/completion.sh | 12 +++++++++++- omz-custom/custom_commands.sh | 6 ++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/omz-custom/completion.sh b/omz-custom/completion.sh index 2d8a7df..72c397d 100644 --- a/omz-custom/completion.sh +++ b/omz-custom/completion.sh @@ -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"} diff --git a/omz-custom/custom_commands.sh b/omz-custom/custom_commands.sh index fbab6b8..840ae20 100644 --- a/omz-custom/custom_commands.sh +++ b/omz-custom/custom_commands.sh @@ -59,12 +59,10 @@ function v() { } function dcu() { - od docker-compose up --build $1 $2 $3 $4 $5 $6 $7 $8 $9 } function dcud () { - od docker-compose up -d --build $1 $2 $3 $4 $5 $6 $7 $8 $9 } @@ -194,6 +192,10 @@ function cmr() { target_branch="master" fi + if [[ $1 == "--target-branch" ]]; then + target_branch=$2 + fi; + glab mr create -a oliver $reviewers --target-branch=$target_branch -t "Merge branch: '$(git branch --show-current)' into $target_branch" --fill -y $draft }