Skip to content

Commit 3f1f867

Browse files
authored
Merge pull request #86 from unixorn/add-git-current-branch
Add `git-current-branch` script
2 parents dd0c7a2 + 8414aa1 commit 3f1f867

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ If you aren't using any ZSH frameworks, or if you're a `bash` user, do the follo
101101
| `git-conflicts` | Seth Messer's [bits and bobs](https://github.com/megalithic/bits-and-bobs/) repo | Show files with conflicts |
102102
| `git-copy-branch-name` | Zach Holman's [dotfiles](https://github.com/holman/dotfiles) | Copy the current branch's name to the clipboard (macOS Only). |
103103
| `git-credit` | Zach Holman's [dotfiles](https://github.com/holman/dotfiles) | Quicker way to assign credit to another author on the latest commit. |
104+
| `git-current-branch` | Joe Block <jpb@unixorn.net> | Prints the name of the current branch, mainly useful in automation scripts. |
104105
| `git-cut-branch` | Ryan Tomayko's [dotfiles](https://github.com/rtomayko/dotfiles) | Create a new branch pointed at **HEAD** and reset the current branch to the head of its tracking branch |
105106
| `git-delete-local-merged` | From a deleted post by @tekkub | Delete all local branches that have been merged into **HEAD**. |
106107
| `git-delete-merged-branches` | ? | Purges all branches that have been merged to a target branch (defaults to branches merged to master). |

bin/git-current-branch

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Print the name of the current branch. Useful for automation scripts.
4+
#
5+
# Copyright 2018, Joe Block <jpb@unixorn.net>
6+
7+
exec git rev-parse --abbrev-ref HEAD

git-extra-commands.plugin.zsh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ zstyle ':completion:*:*:git:*' user-commands \
2929
churn:'List files in ref with change/commit count' \
3030
copy-branch-name:'Copy the current branch name to the clipboard (pbcopy)' \
3131
credit:'A very slightly quicker way to credit an author on the latest commit' \
32+
current-branch:'Print the name of the current branch, helpful for automation'
3233
cut-branch:'Create a new named branch pointed at HEAD and reset the current branch to the head of its tracking branch' \
3334
delete-local-merged:'Delete all local branches that have been merged into HEAD' \
3435
divergence:'List local/remote (incoming/outgoing) changes for current branch' \

0 commit comments

Comments
 (0)