From 7e162147d967dd63dff24ac24bf190d868ef4d29 Mon Sep 17 00:00:00 2001 From: Guangxiong Lin Date: Mon, 20 Sep 2021 20:43:32 +0800 Subject: Add function fco --- .functions | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .functions (limited to '.functions') diff --git a/.functions b/.functions new file mode 100644 index 0000000..07f9afe --- /dev/null +++ b/.functions @@ -0,0 +1,16 @@ +fco () { + local tags branches target + branches=$( + git --no-pager branch --all \ + --format="%(if)%(HEAD)%(then)%(else)%(if:equals=HEAD)%(refname:strip=3)%(then)%(else)%1B[0;34;1mbranch%09%1B[m%(refname:short)%(end)%(end)" \ + | sed '/^$/d' + ) || return + tags=$( + git --no-pager tag | awk '{print "\x1b[35;1mtag\x1b[m\t" $1}' + ) || return + target=$( + (echo $branches; echo $tags) \ + | fzf --no-hscroll --no-multi -n 2 --ansi + ) || return + git checkout $(awk '{print $2}' <<<$target) +} -- cgit v1.2.3