cfg/bin/git-b
Knut Ahlers 3e907e91f3
Add prefix option for branch creation
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2022-09-28 12:27:15 +02:00

21 lines
306 B
Bash
Executable file

#!/bin/bash
set -euo pipefail
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##/}"