From 726cedd375160dbea7aa065fe52cccd20a8efc53 Mon Sep 17 00:00:00 2001 From: NunzioFornitto Date: Wed, 1 Jul 2026 18:20:16 +0200 Subject: [PATCH 01/10] feat(git): add gcb helper to copy current branch name Signed-off-by: NunzioFornitto --- plugins/git/git.plugin.zsh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 9ef60d69a..f8bf09c47 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -68,6 +68,13 @@ function grename() { # (sorted alphabetically by function name) # (order should follow README) # +function gcb() { + # Controlla se siamo in un repository Git + command git rev-parse --is-inside-work-tree &>/dev/null || return + + # Prende il branch corrente, rimuove il newline e lo copia negli appunti + command git branch --show-current | tr -d '\n' | clipcopy +} # Similar to `gunwip` but recursive "Unwips" all recent `--wip--` commits not just the last one function gunwipall() { From 0002238f40497ca69717af9ea0cbf26ffb763fd4 Mon Sep 17 00:00:00 2001 From: Nunzio Fornitto <76222591+NunzioFornitto@users.noreply.github.com> Date: Wed, 1 Jul 2026 18:35:51 +0200 Subject: [PATCH 02/10] refactor(git): rename helper to gcbn and optimize code based on review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- plugins/git/git.plugin.zsh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index f8bf09c47..ff7f41d88 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -68,12 +68,15 @@ function grename() { # (sorted alphabetically by function name) # (order should follow README) # -function gcb() { - # Controlla se siamo in un repository Git +function gcbn() { + # Check if we are in a Git repository command git rev-parse --is-inside-work-tree &>/dev/null || return - # Prende il branch corrente, rimuove il newline e lo copia negli appunti - command git branch --show-current | tr -d '\n' | clipcopy + 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 From 38ef6e62ef9d0830105af2a0711a5cb1c4689f37 Mon Sep 17 00:00:00 2001 From: NunzioFornitto Date: Wed, 29 Jul 2026 16:37:07 +0200 Subject: [PATCH 03/10] 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() { From facf5b905186576e5969866e0cb1c07f35b1e2ed Mon Sep 17 00:00:00 2001 From: NunzioFornitto Date: Wed, 29 Jul 2026 16:48:03 +0200 Subject: [PATCH 04/10] fix(git): fix markdown table syntax and restore alphabetical function ordering --- plugins/git/README.md | 2 +- plugins/git/git.plugin.zsh | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index 935ffbb4e..704ddf404 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -254,7 +254,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` | Copy current branch name to clipboard | | +| `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 9e91beca5..a99ff4e28 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -22,6 +22,16 @@ function git_develop_branch() { echo develop 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 +} # Get the default branch name from common branch names or fallback to remote HEAD function git_main_branch() { @@ -48,16 +58,6 @@ 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 From 3b7ac37b58909869f9ecd1d50f930c0ea6a37be7 Mon Sep 17 00:00:00 2001 From: NunzioFornitto Date: Wed, 29 Jul 2026 16:56:55 +0200 Subject: [PATCH 05/10] style(git): align verb tense in docs and fine-tune function order --- plugins/git/README.md | 2 +- plugins/git/git.plugin.zsh | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index 704ddf404..53953fed5 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -253,7 +253,7 @@ 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 | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index a99ff4e28..f63725eb2 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -22,16 +22,7 @@ function git_develop_branch() { echo develop 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 -} # Get the default branch name from common branch names or fallback to remote HEAD function git_main_branch() { @@ -59,6 +50,17 @@ function git_main_branch() { 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 echo "Usage: $0 old_branch new_branch" From 507138ff064c34e1997ef803cd0ce2f8d51fa63e Mon Sep 17 00:00:00 2001 From: NunzioFornitto Date: Wed, 29 Jul 2026 17:13:18 +0200 Subject: [PATCH 06/10] fix(git): fix markdown table syntax --- plugins/git/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index 53953fed5..6f25a4428 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -253,8 +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 | -| `gbcopy` | Copy current branch name to clipboard | +| `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**) | From 40f8353eb0121fbe035821abc44fbe7bedd1c21d Mon Sep 17 00:00:00 2001 From: NunzioFornitto Date: Wed, 29 Jul 2026 17:25:07 +0200 Subject: [PATCH 07/10] fix(git): fix alphabetical function ordering --- plugins/git/git.plugin.zsh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index f63725eb2..3e1e1c5e1 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -23,7 +23,6 @@ function git_develop_branch() { return 1 } - # Get the default branch name from common branch names or fallback to remote HEAD function git_main_branch() { command git rev-parse --git-dir &>/dev/null || return @@ -50,17 +49,6 @@ function git_main_branch() { 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 echo "Usage: $0 old_branch new_branch" @@ -142,6 +130,17 @@ alias gba='git branch --all' alias gbd='git branch --delete' alias gbD='git branch --delete --force' +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 gbda() { git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch --delete 2>/dev/null } From c04b6c826ba7648b587eb7e87734490d00c56601 Mon Sep 17 00:00:00 2001 From: NunzioFornitto Date: Wed, 29 Jul 2026 17:35:42 +0200 Subject: [PATCH 08/10] feat(git): use git symbolic-ref in gbcopy and align README docs --- plugins/git/README.md | 4 ++-- plugins/git/git.plugin.zsh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index 6f25a4428..d6c5b28b5 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -253,8 +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 | -| `gbcopy` | Copy current branch name to clipboard | +| `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 3e1e1c5e1..ce2cc373d 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -135,7 +135,7 @@ function gbcopy() { command git rev-parse --is-inside-work-tree &>/dev/null || return local branch - branch="$(git_current_branch)" || return + branch="$(command git symbolic-ref --short -q HEAD)" || return [[ -n "$branch" ]] || return 1 print -rn -- "$branch" | clipcopy From b01ea7108650d0f7d1e8feb3989a62839d8601cc Mon Sep 17 00:00:00 2001 From: NunzioFornitto Date: Wed, 29 Jul 2026 17:48:31 +0200 Subject: [PATCH 09/10] refactor(git): move gbcopy to Functions section, update git-dir check and sync README --- plugins/git/git.plugin.zsh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index ce2cc373d..e01e66713 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -49,6 +49,17 @@ function git_main_branch() { 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="$(command git symbolic-ref --short -q HEAD)" || return + [[ -n "$branch" ]] || return 1 + + print -rn -- "$branch" | clipcopy +} + function grename() { if [[ -z "$1" || -z "$2" ]]; then echo "Usage: $0 old_branch new_branch" @@ -130,17 +141,6 @@ alias gba='git branch --all' alias gbd='git branch --delete' alias gbD='git branch --delete --force' -function gbcopy() { - # Check if we are in a Git repository - command git rev-parse --is-inside-work-tree &>/dev/null || return - - local branch - branch="$(command git symbolic-ref --short -q HEAD)" || return - [[ -n "$branch" ]] || return 1 - - print -rn -- "$branch" | clipcopy -} - function gbda() { git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch --delete 2>/dev/null } From 854caf0228b04bf81a09cd2a40128a294465f7b0 Mon Sep 17 00:00:00 2001 From: NunzioFornitto Date: Wed, 29 Jul 2026 17:49:17 +0200 Subject: [PATCH 10/10] refactor(git): move gbcopy to Functions section, update git-dir check and sync README --- plugins/git/git.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index e01e66713..9a8727d2c 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -51,7 +51,7 @@ function git_main_branch() { function gbcopy() { # Check if we are in a Git repository - command git rev-parse --is-inside-work-tree &>/dev/null || return + command git rev-parse --git-dir &>/dev/null || return local branch branch="$(command git symbolic-ref --short -q HEAD)" || return