I'm trying to create neovim fzf command FzfGBranches to use git branch -a as input, and use git log --oneline as fzf preview:
command! -bang -nargs=0 FzfGBranches
\ call fzf#vim#grep(
\ "git branch -a", 1,
\ fzf#vim#with_preview({
\ 'options': [
\ '--prompt', '*Branches> ',
\ '--bind', 'ctrl-d:page-down,ctrl-u:page-up',
\ ],
\ 'placeholder': "echo {} | rev | cut -d'*' -f1 | rev | git log --oneline --graph --date=short --color=always --pretty=\"format:%C(auto)%cd %h%d %s\"",
\ }), <bang>0)
When call FzfGBranches command, it show up and seems good, but when I press up/down keys, the preview (on the right side) does not refresh. See below screenshot:
How should I specify the --preview option in fzf.vim?

tl;dr…
fzf#rungit logcommand accept the branch selected from FZFDeets
First off,
placeholderis undocumented, so I didn't spend time down this path. Conceptually, this is possible, so there has to be a simpler way. Enterfzf#run. This is a thin wrapper around the actual FZF tool. It only requires asource,sink, andoptions. Most of the magic would be happening in your options string.Secondly, your last segment in the placeholder — to show a log of the changes in the branch — will always show the log of the branch you're currently on.
What you want to do is to pipe the current branch highlighted in FZF through to your
git logcommand. Something along the lines ofNow, we can pipe the branch name from stdin into the git command.
With this working, we are ready to build a working command in Vim
Breaking down the
--previewsegments…echo {}to report the current FZF selectoinsed \"s/\*//\"to remove any*characters, if any. This is the case for the current branchsed \"s/^ *//;s/ *$//\"to remove any whitespaces from the beginning and the end of the string gotten fromecho {}xargs git smart-logpipes in the result of the previous three as an argument into oursmart-log