From 2ea948e05be0fc927ef5d886a4c7d05f7e354ab7 Mon Sep 17 00:00:00 2001 From: Nunzio Fornitto <76222591+NunzioFornitto@users.noreply.github.com> Date: Wed, 16 Sep 2026 10:39:06 +0200 Subject: [PATCH] feat(git): add `gbcopy` (#13847) Signed-off-by: NunzioFornitto --- plugins/git/README.md | 1 + plugins/git/git.plugin.zsh | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/plugins/git/README.md b/plugins/git/README.md index 11010ae9f..930a4b8f8 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -255,6 +255,7 @@ receive further support. | `git_current_user_name` | Returns the `user.name` config value (Lives in `lib/git.zsh`) | | `git_develop_branch` | Returns the name of the “development” branch: `dev`, `devel`, `development` if they exist, `develop` otherwise | | `git_main_branch` | Returns the name of the main branch: `main` if it exists, `master` otherwise | +| `gbcopy` | Copies current branch name to clipboard | | `grename ` | Renames branch `` to ``, including on the origin remote | | `gbda` | Deletes all merged branches | | `gbds` | Deletes all squash-merged branches (**Note: performance degrades with number of branches**) | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 7d6f375d8..dc0f2763e 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -49,6 +49,16 @@ function git_main_branch() { return 1 } +function gbcopy() { + command git rev-parse --git-dir &>/dev/null || return + + local branch + branch="$(git_current_branch)" || return + [[ -n "$branch" ]] || return 1 + + print -rn -- "$branch" | clipcopy +} + function grename() { if [[ -z "$1" || -z "$2" ]]; then echo "Usage: $0 old_branch new_branch"