home/git: bundle homebrewn external git commands

This commit is contained in:
2024-07-03 23:35:52 +02:00
parent aed71f1d7b
commit f053a0f70a
4 changed files with 63 additions and 3 deletions

View File

@@ -0,0 +1,11 @@
set -euo pipefail
if [ -n "${1:-}" ]; then
git switch "$1"
exit 0
fi
BRANCHES=$(cat <(git branch) <(git branch --remotes) | grep --invert-match '^\*\|HEAD ->' | sed 's|^\s*||')
CHOSEN_BRANCH=$(fzf --reverse --info=inline --preview 'git show --color {}' <<<"$BRANCHES")
CLEAN_BRANCH_NAME=$(sed 's|^\s*.*/||' <<<"$CHOSEN_BRANCH")
git switch "$CLEAN_BRANCH_NAME"