From 92a9fee013b13f3074856ebec2b1f5dc95d9931e Mon Sep 17 00:00:00 2001 From: Efi Shtain Date: Thu, 30 Oct 2025 20:04:52 +0200 Subject: [PATCH] feat(git): add listing latest branches add glb function to git plugin which allows listing the latest X branches (10 by default) make it easy to work with multiple branches when it is hard remembering the names --- plugins/git/README.md | 1 + plugins/git/git.plugin.zsh | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/plugins/git/README.md b/plugins/git/README.md index 0ecbea7b6..616d3c842 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -268,6 +268,7 @@ receive further support. | `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**) | +| `glb` | List latest switched to branches (default 10, can use glb X to get latest X branches) ### Work in Progress (WIP) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index a0052891a..239e5a716 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -71,6 +71,12 @@ function grename() { fi } +# List latest X (default 10) used branches +glb() { + local count=${1:-10} + git reflog | grep 'checkout: moving' | awk '{print $8}' | awk '!seen[$0]++' | head -n "$count" +} + # # Functions Work in Progress (WIP) # (sorted alphabetically by function name)