Replies: 7 comments 10 replies
-
why dont you use one? all a config file is a file that gets sourced by the shell startup scripts (most of the time). #!/bin/bash
export FZF_MOVEMENT="--bind='ctrl-s:preview-page-down' \
--bind='alt-p:toggle-preview' \
--bind='ctrl-a:preview-page-up' \
--bind='ctrl-u:half-page-up+refresh-preview' \
--bind='alt-u:page-up+refresh-preview' \
--bind='ctrl-d:half-page-down+refresh-preview' \
--bind='alt-d:page-down+refresh-preview' \
--bind='alt-y:yank' \
--bind='ctrl-y:kill-line' \
--bind='alt-g:ignore' \
--bind='ctrl-g:top' \
--bind='alt-a:toggle-all' \
--bind='alt-s:toggle-sort' \
--bind='alt-h:backward-char+refresh-preview' \
--bind='alt-l:forward-char+refresh-preview' \
--bind='ctrl-l:clear-screen'"
export FZF_DEFAULT_COMMAND="rg -uu \
--files \
-H"
export FZF_ALT_COMMAND="fd -uu -t f"
export FZF_DEFAULT_OPTS="$FZF_MOVEMENT \
--bind='ctrl-h:execute(moreman {})' \
--bind='ctrl-p:toggle-preview' \
--bind='ctrl-v:execute(nvimpager {})' \
--tiebreak='length,index' \
--preview-window 'right:100:wrap:cycle' \
--height=100 \
--exact \
--info='inline' \
--cycle \
--reverse \
--multi \
--ansi"
if [[ -z "$DISPLAY" ]]; then
FZF_DEFAULT_OPTS+="
--color=info:1 \
--color=prompt:2 \
--color=pointer:3 \
--color=hl+:4 \
--color=marker:6 \
--color=spinner:7 \
--color=header:8 \
--color=border:9 \
--color=hl:122 \
--color=preview-fg:11 \
--color=fg:13 \
--color=fg+:14"
fi and can even be called indirectly, this second file is where i source all my custom fzf bindings and scripts and functions that get reused by other scripts (including the default options) # Setup fzf
# ---------
PGM="$HOME/project/Man-fzf-scripts"
export PGM
while read line;
do
[[ -r "$line" ]] && source "${PGM}${line}
done <<EOF
/fzf/completion.bash
/fzf/fzf-extra.bash
/fzf/fzf.bind.bash
/fzf/conf/.fzfrc
/fzf/fzf-ide.bash
/fzf/fzcmp
/fzf/fzf-ide.bash
EOF
export FZF_TMUX=1 this functionality exists as is, i just source this from my bashrc or bash.bashrc (or zsh / fish equivalent and there you go config file) ironically its actually named .fzfrc but generally speaking, config files are most of the time just scripts that get executed. hope this gives you some ideals to work with. as a note FZF_DEFAULT_OPTIONS while used by fzf and may be set by fzf scripts it is actually a shell process so your best place to look for creating configure files would be your shell docs for best practices :). |
Beta Was this translation helpful? Give feedback.
-
hmm i guess my point that I'm trying to scope is without recompiling every time you make a modification im not sure its possible to have an independent of shell config file. However FZF_DEFAULT_OPTIONS, is not just used by fzf, its used by tmux vim and all the various creations that have come after it. the other thing is, with its own compiled config would you still be able to manipulate in in the same way via script (one of the magics of a variable is you can manipulate it per situation. with a config file i don't see how you could do some of the variable hacks that are currently in use by myself and others. (though this could be due to my limited understanding and not an actual limitation) |
Beta Was this translation helpful? Give feedback.
-
The problem I face without a (global) config file is that theme switching (light to dark etc.) is impossible. Changing an env variable (FZF_DEFAULT_OPTIONS) will not affect all future fzf instances, spawned from any other terminal (or e.g. sxhkd or tmux on Linux). A global config file can easily be linked to a dark and light theme. |
Beta Was this translation helpful? Give feedback.
-
I'm sourcing a file in my .config directory, ~/.config/fzf/fzfdefaults, anyway; it'd be much simpler for me if fzf already knew where to look. And I very much like the idea of making a change to the file and having the new opts take effect immediately, rather than having to source. IMHO, of course. |
Beta Was this translation helpful? Give feedback.
-
You have some valid points. What do you think about having a separate variable that points to the location of the config file? Because 1. it seems there's no universal agreement on where it should be, and 2. so fzf doesn't have to check for the existence of the file at the default location when it's not used. # Read config file only if this variable is set
export FZF_DEFAULT_OPTS_FILE=~/.fzfrc |
Beta Was this translation helpful? Give feedback.
-
Hi @junegunn The I see that there is a separate Was this intentional? |
Beta Was this translation helpful? Give feedback.
-
I'm guessing we should define the |
Beta Was this translation helpful? Give feedback.
-
My FZF_DEFAULT_OPTS variable is getting quite long and hairy, which got me thinking - is it the time for fzf to be able to read its configuration from a proper config file (~/.fzfrc, ~/.config/fzf/config or something similar ???)
Beta Was this translation helpful? Give feedback.
All reactions