This commit is contained in:
Nunzio Fornitto 2026-08-06 10:16:30 +02:00 committed by GitHub
commit a909317b75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View file

@ -254,6 +254,7 @@ receive further support.
| `git_current_user_name` | Returns the `user.name` 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_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` | Copies current branch name to clipboard |
| `grename <old> <new>` | Renames branch `<old>` to `<new>`, including on the origin remote | | `grename <old> <new>` | Renames branch `<old>` to `<new>`, including on the origin remote |
| `gbda` | Deletes all merged branches | | `gbda` | Deletes all merged branches |
| `gbds` | Deletes all squash-merged branches (**Note: performance degrades with number of branches**) | | `gbds` | Deletes all squash-merged branches (**Note: performance degrades with number of branches**) |

View file

@ -49,6 +49,17 @@ function git_main_branch() {
return 1 return 1
} }
function gbcopy() {
# Check if we are in a Git repository
command git rev-parse --git-dir &>/dev/null || return
local branch
branch="$(command git symbolic-ref --short -q HEAD)" || return
[[ -n "$branch" ]] || return 1
print -rn -- "$branch" | clipcopy
}
function grename() { function grename() {
if [[ -z "$1" || -z "$2" ]]; then if [[ -z "$1" || -z "$2" ]]; then
echo "Usage: $0 old_branch new_branch" echo "Usage: $0 old_branch new_branch"