From 38ef6e62ef9d0830105af2a0711a5cb1c4689f37 Mon Sep 17 00:00:00 2001 From: NunzioFornitto Date: Wed, 29 Jul 2026 16:37:07 +0200 Subject: [PATCH] refactor(git): rename function to gbcopy, reorder, and update docs --- plugins/git/README.md | 3 ++- plugins/git/git.plugin.zsh | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index c0a651375..935ffbb4e 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -253,7 +253,8 @@ receive further support. | `git_current_user_email` | Returns the `user.email` config value (Lives in `lib/git.zsh`) | | `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 | +| `git_main_branch` | Returns the name of the main branch: `main` if it exists, `master` otherwise +| `gbcopy` | Copy 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 ff7f41d88..9e91beca5 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -48,6 +48,16 @@ function git_main_branch() { echo master return 1 } +function gbcopy() { + # Check if we are in a Git repository + command git rev-parse --is-inside-work-tree &>/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 @@ -68,16 +78,6 @@ function grename() { # (sorted alphabetically by function name) # (order should follow README) # -function gcbn() { - # Check if we are in a Git repository - command git rev-parse --is-inside-work-tree &>/dev/null || return - - local branch - branch="$(git_current_branch)" || return - [[ -n "$branch" ]] || return 1 - - print -rn -- "$branch" | clipcopy -} # Similar to `gunwip` but recursive "Unwips" all recent `--wip--` commits not just the last one function gunwipall() {