summaryrefslogtreecommitdiffstats
path: root/.config/fzf/fzf.bash
diff options
context:
space:
mode:
Diffstat (limited to '.config/fzf/fzf.bash')
-rw-r--r--.config/fzf/fzf.bash69
1 files changed, 69 insertions, 0 deletions
diff --git a/.config/fzf/fzf.bash b/.config/fzf/fzf.bash
new file mode 100644
index 0000000..f567a6d
--- /dev/null
+++ b/.config/fzf/fzf.bash
@@ -0,0 +1,69 @@
+# ——————————————————————————————————————————————————————————————————————————————
+# fzf configuration
+#
+# See https://github.com/junegunn/fzf
+# ——————————————————————————————————————————————————————————————————————————————
+
+fzf_default_usage='Alt+Y copy to clipboard
+Alt+/ move/hide preview'
+fzf_ctrl_t_usage='Ctrl+Y select
+Alt+Y copy to clipboard
+Alt+/ move/hide preview'
+fzf_ctrl_r_usage='Alt+R show surrounding entries
+Ctrl+R sort by relevance/recency
+Alt+Y copy to clipboard'
+fzf_alt_c_usage='Alt+Y copy to clipboard
+Alt+/ move/hide preview'
+
+# This is used by the Ctrl+T, Ctrl+R, and Alt+C bindings, unless redefined
+export FZF_DEFAULT_OPTS="
+--walker file,dir,follow,hidden
+--walker-skip .git,node_modules
+
+--bind tab:down,btab:up
+--bind 'alt-y:execute-silent(wl-copy {..})+abort'
+--bind 'alt-/:change-preview-window(down|hidden|)'
+
+--layout reverse --height 50%
+--color header:italic
+--footer '$fzf_default_usage'
+"
+
+# ——————————————————————————————————————————————————————————————————————————————
+# Ctrl+T, Ctrl+R, Alt+C function options
+#
+# See https://github.com/junegunn/fzf#key-bindings-for-command-line
+# ——————————————————————————————————————————————————————————————————————————————
+
+# (Ctrl+T) Paste the selected files and directories onto the command-line
+export FZF_CTRL_T_OPTS="
+--walker file,follow,hidden
+--preview 'bat --number --color=always {}'
+--bind ctrl-y:toggle
+--bind 'alt-/:change-preview-window(down|hidden|)'
+--footer '$fzf_ctrl_t_usage'
+"
+
+# (Ctrl+R) Paste the selected command from history onto the command-line
+export FZF_CTRL_R_OPTS="
+--bind 'alt-y:execute-silent(wl-copy {2..})+abort'
+--footer '$fzf_ctrl_r_usage'
+"
+
+# (Alt+C) `cd` into the selected directory
+export FZF_ALT_C_OPTS="
+--walker dir,follow,hidden
+--preview 'tree -C {}'
+--bind 'alt-/:change-preview-window(down|hidden|)'
+--footer '$fzf_alt_c_usage'
+"
+
+# ——————————————————————————————————————————————————————————————————————————————
+# ** fuzzy completion
+#
+# See https://github.com/junegunn/fzf#customizing-fuzzy-completion-for-bash-and-zsh
+# ——————————————————————————————————————————————————————————————————————————————
+
+# ——————————————————————————————————————————————————————————————————————————————
+
+eval "$(fzf --bash)"