.dotfiles/zsh/.fzf.zsh

40 lines
1.4 KiB
Bash
Executable file

# ------------- FZF Configuration -------------
# Determine the FZF path based on the available package manager
if command -v fzf >/dev/null; then
# Path when fzf is installed directly
FZF_PATH="$(dirname "$(command -v fzf)")"
elif [[ -x "/run/current-system/sw/bin/fzf" ]]; then
# Path when fzf is installed via Nix
FZF_PATH="/run/current-system/sw/bin/fzf"
elif command -v brew >/dev/null; then
# Path when fzf is installed via Homebrew (Darwin)
FZF_PATH="$(brew --prefix)/opt/fzf"
else
# Fallback location for FZF
FZF_PATH="/usr/local/opt/fzf"
fi
# Ensure the FZF binary is in the PATH
if [[ ! "$PATH" == *"$FZF_PATH/bin"* ]]; then
PATH="${PATH:+${PATH}:}$FZF_PATH/bin" # Add FZF to PATH if not already included
fi
# Load fzf theme options if the theme file exists
FZF_THEME_FILE="${HOME}/.local/bin/scripts/fzf_theme"
[[ -f "$FZF_THEME_FILE" ]] && export FZF_DEFAULT_OPTS="$("$FZF_THEME_FILE")" # Set FZF default options
# Auto-completion and Key Bindings Setup
# ----------------------------------------
if [[ $- == *i* ]]; then
# Load fzf key-bindings if available
[[ -f "$HOME/.fzf/key-bindings.zsh" ]] && . "$HOME/.fzf/key-bindings.zsh"
# Load fzf completion if available
[[ -f "$HOME/.fzf/completion.zsh" ]] && . "$HOME/.fzf/completion.zsh"
# Optional: Enable history search with fzf
# Uncomment the line below to activate the fzf history widget
# bindkey '^R' fzf-history-widget # Bind Ctrl+R to fzf history widget
fi