mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-19 09:03:43 -05:00
added fco_preview: might be really bad code, but it "works for me!"
19
Examples.md
19
Examples.md
@@ -385,6 +385,24 @@ fco() {
|
|||||||
fzf-tmux -l30 -- --no-hscroll --ansi +m -d "\t" -n 2) || return
|
fzf-tmux -l30 -- --no-hscroll --ansi +m -d "\t" -n 2) || return
|
||||||
git checkout $(echo "$target" | awk '{print $2}')
|
git checkout $(echo "$target" | awk '{print $2}')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# fco_preview - checkout git branch/tag, with a preview showing the commits between the tag/branch and HEAD
|
||||||
|
fco_preview() {
|
||||||
|
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 --no-hscroll --no-multi --delimiter="\t" -n 2 \
|
||||||
|
--preview="git log -200 --pretty=format:%s $(echo {+2..} | sed 's/$/../' )" ) || return
|
||||||
|
git checkout $(echo "$target" | awk '{print $2}')
|
||||||
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -919,4 +937,3 @@ zle -N _fzf_marker_placeholder_widget
|
|||||||
bindkey "${FZF_MARKER_MAIN_KEY:-\C-@}" _fzf_marker_main_widget
|
bindkey "${FZF_MARKER_MAIN_KEY:-\C-@}" _fzf_marker_main_widget
|
||||||
bindkey "${FZF_MARKER_PLACEHOLDER_KEY:-\C-v}" _fzf_marker_placeholder_widget
|
bindkey "${FZF_MARKER_PLACEHOLDER_KEY:-\C-v}" _fzf_marker_placeholder_widget
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user