Created
February 8, 2023 01:13
-
-
Save bastos/f41a47a1d201ba93feb46a6fe10434aa to your computer and use it in GitHub Desktop.
Bash script to select a branch and checkout using charmbracelet/gum
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
#!/bin/sh | |
if ! [ -d .git ]; then | |
echo "This directory does not have a Git repository" | |
exit 1 | |
fi | |
repository=$(git branch | awk '{print $NF}' | sort -r | gum filter --limit=1) | |
if [ -z "$repository" ]; then | |
echo "No branch selected" | |
exit 1 | |
else | |
git checkout $repository | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment