shedali
11/25/2018 - 7:50 PM

fuzzy checkout

fuzzy checkout

fco () {
	local tags branches target
	tags=$(
		git tag | awk '{print "\x1b[31;1mtag\x1b[m\t" $1}'
	)  || return
	branches=$(
		git branch --all | grep -v HEAD |
			sed "s/.* //" | sed "s#remotes/[^/]*/##" |
			sort -u | awk '{print "\x1b[34;1mbranch\x1b[m\t" $1}'
	)  || return
	target=$(
		(
			echo "$tags"
			echo "$branches"
		) |
			fzf-tmux -l80 -- --no-hscroll --ansi +m -d "\t" -n 2
	)  || return
	hub checkout $(echo "$target" | awk '{print $2}')
}