40 lines
1.3 KiB
Bash
Executable file
40 lines
1.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# Indicate the shell explicitly
|
|
export FZF_SHELL="bash"
|
|
|
|
# Detect OS and environment
|
|
IS_WSL=false
|
|
|
|
if [[ -f /proc/sys/kernel/osrelease ]] && grep -qi "microsoft" /proc/sys/kernel/osrelease; then
|
|
IS_WSL=true
|
|
fi
|
|
|
|
# Determine fzf path if installed
|
|
if command -v fzf >/dev/null; then
|
|
export FZF_PATH="$(dirname "$(command -v fzf)")"
|
|
else
|
|
export FZF_PATH=""
|
|
fi
|
|
|
|
# Source fzf key bindings and completions based on environment
|
|
if command -v fzf >/dev/null; then
|
|
# Linux or macOS typical install
|
|
[ -f "$FZF_PATH/key-bindings.bash" ] && source "$FZF_PATH/key-bindings.bash"
|
|
[ -f "$FZF_PATH/completion.bash" ] && source "$FZF_PATH/completion.bash"
|
|
elif $IS_WSL; then
|
|
# Windows install accessed via WSL
|
|
WIN_FZF_DIR="/mnt/c/Program Files/fzf/shell"
|
|
[ -f "$WIN_FZF_DIR/key-bindings.bash" ] && source "$WIN_FZF_DIR/key-bindings.bash"
|
|
[ -f "$WIN_FZF_DIR/completion.bash" ] && source "$WIN_FZF_DIR/completion.bash"
|
|
fi
|
|
|
|
# Load fzf theme if available
|
|
FZF_THEME_SCRIPT="$HOME/.local/bin/scripts/fzf_theme.sh"
|
|
if [[ -f "$FZF_THEME_SCRIPT" ]]; then
|
|
# Use custom theme script if it exists
|
|
export FZF_DEFAULT_OPTS="$($FZF_THEME_SCRIPT) --height 40% --layout=reverse --border"
|
|
else
|
|
# Fallback to default options
|
|
export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border"
|
|
fi
|