checkout fuzzy, but doesn't work

This commit is contained in:
Noah Masur 2020-11-25 12:18:11 -05:00
parent 736df8a3df
commit 0a7b65c51f

18
bin/git-checkout-fuzzy-2 Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
gcb() {
result=$(git branch -a --color=always | grep -v '/HEAD\s' | sort |
fzf --height 50% --border --ansi --tac --preview-window right:70% \
--preview 'git log --oneline --graph --date=short --pretty="format:%C(auto)%cd %h%d %s" $(sed s/^..// <<< {} | cut -d" " -f1) | head -'$LINES |
sed 's/^..//' | cut -d' ' -f1)
if [[ $result != "" ]]; then
if [[ $result == remotes/* ]]; then
git checkout --track $(echo $result | sed 's#remotes/##')
else
git checkout "$result"
fi
fi
}
gcb