Last active
August 29, 2015 14:21
-
-
Save tyrelsouza/ffad8cf2790581ff82d7 to your computer and use it in GitHub Desktop.
Copy git branch to your clipboard (needs xsel or pbcopy installed)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cpbr { | |
if branch=$(git symbolic-ref --short -q HEAD) | |
then | |
if command -v pbcopy 2>/dev/null; then | |
printf "$branch" | pbcopy | |
echo "$branch copied to your clipboard using pbcopy" | |
elif command -v xsel 2>/dev/null; then | |
printf "$branch" | xsel --clipboard | |
echo "$branch copied to your clipboard using xsel" | |
else | |
echo "Please install xsel or pbcopy" | |
fi | |
else | |
echo "No branch, not copying" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment