mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-16 23:33:39 -05:00
fco for tags and branches
19
Examples.md
19
Examples.md
@@ -135,11 +135,26 @@ fbr() {
|
||||
fzf-tmux -d $(( 2 + $(wc -l <<< "$branches") )) +m) &&
|
||||
git checkout $(echo "$branch" | sed "s/.* //" | sed "s#remotes/[^/]*/##")
|
||||
}
|
||||
|
||||
# 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
|
||||
target=$(
|
||||
(echo "$tags"; echo "$branches") |
|
||||
fzf-tmux -l30 -- --no-hscroll --ansi +m -d "\t" -n 2) || return
|
||||
git checkout $(echo "$target" | awk '{print $2}')
|
||||
}
|
||||
```
|
||||
|
||||
```sh
|
||||
# fco - checkout git commit
|
||||
fco() {
|
||||
# fcoc - checkout git commit
|
||||
fcoc() {
|
||||
local commits commit
|
||||
commits=$(git log --pretty=oneline --abbrev-commit --reverse) &&
|
||||
commit=$(echo "$commits" | fzf --tac +s +m -e) &&
|
||||
|
||||
Reference in New Issue
Block a user