Skip to content

Commit

Permalink
Don't assume bat is installed
Browse files Browse the repository at this point in the history
- Don't assume `bat` is installed for use in previews.
- If it is installed, don't assume is installed as `bat` - it might be
  installed as `batcat`.

Signed-off-by: Joe Block <[email protected]>
  • Loading branch information
unixorn committed Mar 6, 2024
1 parent c9a3506 commit 3794e8c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion fzf-zsh-plugin.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,16 @@ fi
# - An advanced preview using a `less` preprocessor, capable of showing a wide range of formats, incl. images, dirs,
# CSVs, and other binary files (depending on available tooling).
_fzf_preview() {
foolproofPreview='([[ -f {} ]] && (bat --style=numbers --color=always {} || cat {})) || ([[ -d {} ]] && (tree -C {} | less)) || echo {} 2>/dev/null | head -n 200'
_fzf_preview_pager='cat'
foolproofPreview='cat {}'
if _fzf_has bat; then
_fzf_preview_pager='bat'
foolproofPreview='([[ -f {} ]] && (bat --style=numbers --color=always {} || cat {})) || ([[ -d {} ]] && (tree -C {} | less)) || echo {} 2>/dev/null | head -n 200'
fi
if _fzf_has batcat; then
_fzf_preview_pager='batcat'
foolproofPreview='([[ -f {} ]] && (batcat --style=numbers --color=always {} || cat {})) || ([[ -d {} ]] && (tree -C {} | less)) || echo {} 2>/dev/null | head -n 200'
fi
local preview
[[ "$FZF_PREVIEW_ADVANCED" == true ]] \
&& preview="lessfilter-fzf {}" \
Expand Down

0 comments on commit 3794e8c

Please sign in to comment.