From e523aa74b2afc5f8142c8cc27efcebac314d7b86 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 24 Feb 2025 12:22:25 +0100 Subject: [PATCH] git: Add git-bug status toggle alias gbo Requires bug-id to be passed and toggles the corresponding bug open or closed (`gbo `). Otherwise just passes through any arguments to the `git-bug bug status` command. --- vcs/git/config/sh/alias.d/git-bug.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/vcs/git/config/sh/alias.d/git-bug.sh b/vcs/git/config/sh/alias.d/git-bug.sh index d0485fc..ecd025f 100644 --- a/vcs/git/config/sh/alias.d/git-bug.sh +++ b/vcs/git/config/sh/alias.d/git-bug.sh @@ -58,12 +58,22 @@ if [ -x "$(command -v vipe)" ] && [ -x "$(command -v jq)" ]; then } fi -# TODO: edit bug title alias gbte='git-bug bug title edit' -# TODO: Implement toggle function -# grab current status and then open or close accordingly -alias gbo='git-bug bug status close' +# Toggles status of bug passed +# or passes through to bug status +gbo() { + if git-bug bug status "$1" >/dev/null 2>/dev/null; then + cur=$(git-bug bug status "$1") + if [ "$cur" = "open" ]; then + git-bug bug status close "$1" + elif [ "$cur" = "closed" ]; then + git-bug bug status open "$1" + fi + else + git-bug bug status "$@" + fi +} alias gbp='git-bug push' alias gbl='git-bug pull'