From bba51101ee4604e56c621574970b98ffdb32f844 Mon Sep 17 00:00:00 2001 From: Anton Bobov Date: Wed, 16 Jul 2025 22:14:30 +0500 Subject: fzf: Customize Ctrl+T command --- files/.zsh/rc/S90_fzf | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/files/.zsh/rc/S90_fzf b/files/.zsh/rc/S90_fzf index 0a27947..847509a 100644 --- a/files/.zsh/rc/S90_fzf +++ b/files/.zsh/rc/S90_fzf @@ -88,3 +88,32 @@ export FZF_CTRL_R_OPTS="$( --prompt ' Global History > ' FZF_FTW )" + +_setup_fzf_ctrl_t_options() { + # + # fzf Ctrl+T options + # https://github.com/junegunn/fzf#key-bindings-for-command-line + # + local preview_command + if command -v bat >/dev/null 2>&1; then + preview_command="bat --color=always --line-range :500" + else + preview_command="cat" + fi + local find_command + if [ $(command -v fdfind) ] ; then + find_command="fdfind --type file --hidden" + elif [ $(command -v fd) ] ; then + find_command="fd --type file --hidden" + fi + + FZF_CTRL_T_OPTS="${FZF_CTRL_T_OPTS:-} --preview '$preview_command {}'" + FZF_CTRL_T_OPTS="${FZF_CTRL_T_OPTS} --bind 'ctrl-/:change-preview-window(down|hidden|)'" + FZF_CTRL_T_OPTS="${FZF_CTRL_T_OPTS} --bind 'ctrl-v:become(\"${EDITOR:-vim}\" -- {+} /dev/tty)'" + FZF_CTRL_T_OPTS="${FZF_CTRL_T_OPTS} --bind 'ctrl-a:reload($find_command),ctrl-h:reload(eval \"${FZF_DEFAULT_COMMAND}\")'" + FZF_CTRL_T_OPTS="${FZF_CTRL_T_OPTS} --header 'enter select · ^/ toggle preview · ^v edit · ^(a|h) toggle hidden'" + + export FZF_CTRL_T_OPTS +} +_setup_fzf_ctrl_t_options +unfunction _setup_fzf_ctrl_t_options -- cgit v1.2.3