From 3e907e91f39efebc16ca6be5340b61ed8e2bd707 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Wed, 28 Sep 2022 12:27:15 +0200 Subject: [PATCH] Add prefix option for branch creation Signed-off-by: Knut Ahlers --- bin/git-b | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/bin/git-b b/bin/git-b index 6003341..5b4db0e 100755 --- a/bin/git-b +++ b/bin/git-b @@ -2,4 +2,20 @@ set -euo pipefail -git checkout -b $(slugify "$@" | cut -c 1-72) +prefix="" + +while getopts ":p:" o; do + case "${o}" in + p) + prefix="${OPTARG}" + ;; + *) + usage + fatal "Invalid option -- ${OPTARG}" + ;; + esac +done +shift $((OPTIND - 1)) + +branchname="${prefix}/$(slugify "$@" | cut -c 1-72)" +git checkout -b "${branchname##/}"