From 5b87d691490e0dad7f4b23b23842bcb26a75c35f Mon Sep 17 00:00:00 2001 From: Diogo Lemos Date: Sat, 15 Jun 2019 17:16:51 +0100 Subject: [PATCH] Same changes to fco as fco_preview from previous edit. --- Examples.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Examples.md b/Examples.md index 3536965..42f3fef 100644 --- a/Examples.md +++ b/Examples.md @@ -423,16 +423,17 @@ fbr() { # fco - checkout git branch/tag 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 + 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 "$tags"; echo "$branches") | - fzf-tmux -l30 -- --no-hscroll --ansi +m -d "\t" -n 2) || return - git checkout $(echo "$target" | awk '{print $2}') + (echo "$branches"; echo "$tags") | + fzf --no-hscroll --no-multi -n 2 \ + --ansi) || return + git checkout $(awk '{print $2}' <<<"$target" ) }