mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-19 09:03:43 -05:00
Same changes to fco as fco_preview from previous edit.
17
Examples.md
17
Examples.md
@@ -423,16 +423,17 @@ fbr() {
|
|||||||
# fco - checkout git branch/tag
|
# fco - checkout git branch/tag
|
||||||
fco() {
|
fco() {
|
||||||
local tags branches target
|
local tags branches target
|
||||||
tags=$(
|
|
||||||
git tag | awk '{print "\x1b[31;1mtag\x1b[m\t" $1}') || return
|
|
||||||
branches=$(
|
branches=$(
|
||||||
git branch --all | grep -v HEAD |
|
git --no-pager branch --all \
|
||||||
sed "s/.* //" | sed "s#remotes/[^/]*/##" |
|
--format="%(if)%(HEAD)%(then)%(else)%(if:equals=HEAD)%(refname:strip=3)%(then)%(else)%1B[0;34;1mbranch%09%1B[m%(refname:short)%(end)%(end)" \
|
||||||
sort -u | awk '{print "\x1b[34;1mbranch\x1b[m\t" $1}') || return
|
| sed '/^$/d') || return
|
||||||
|
tags=$(
|
||||||
|
git --no-pager tag | awk '{print "\x1b[35;1mtag\x1b[m\t" $1}') || return
|
||||||
target=$(
|
target=$(
|
||||||
(echo "$tags"; echo "$branches") |
|
(echo "$branches"; echo "$tags") |
|
||||||
fzf-tmux -l30 -- --no-hscroll --ansi +m -d "\t" -n 2) || return
|
fzf --no-hscroll --no-multi -n 2 \
|
||||||
git checkout $(echo "$target" | awk '{print $2}')
|
--ansi) || return
|
||||||
|
git checkout $(awk '{print $2}' <<<"$target" )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user