diff options
| author | subh <subh@example.com> | 2026-01-19 21:47:02 +0530 |
|---|---|---|
| committer | subh <subh@example.com> | 2026-01-19 21:47:02 +0530 |
| commit | 65aad59ef0802708a8a7c8a312755232cc1823d3 (patch) | |
| tree | fe0a437f3e9a71ab5b9197d9b8fa72c24d2170ea /scripts/fzf.sh | |
initial commit
Diffstat (limited to 'scripts/fzf.sh')
| -rwxr-xr-x | scripts/fzf.sh | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/scripts/fzf.sh b/scripts/fzf.sh new file mode 100755 index 0000000..5ef3dae --- /dev/null +++ b/scripts/fzf.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +set -e + +ZSHRC="$HOME/.zshrc" + +echo "▶ Installing fzf (Arch)…" +sudo pacman -S --needed fzf + +echo "▶ Updating ~/.zshrc…" + +# Remove unsupported Ctrl-R command if present +sed -i '/FZF_CTRL_R_COMMAND/d' "$ZSHRC" + +# Append config only if not already present +if ! grep -q "==== fzf key bindings (Arch Linux) ====" "$ZSHRC"; then +cat <<'EOF' >> "$ZSHRC" + +# ==== fzf key bindings (Arch Linux) ==== + +# Remove unsupported custom Ctrl-R command (prevents warning) +unset FZF_CTRL_R_COMMAND + +# fzf defaults +export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border" +export FZF_CTRL_R_OPTS="--tac --preview 'echo {}' --preview-window down:3:hidden:wrap" + +# Source fzf (Arch path) +if [[ -f /usr/share/fzf/key-bindings.zsh ]]; then + source /usr/share/fzf/key-bindings.zsh +fi + +if [[ -f /usr/share/fzf/completion.zsh ]]; then + source /usr/share/fzf/completion.zsh +fi + +# Ensure Ctrl+R works in vi insert mode +bindkey -M viins '^R' fzf-history-widget + +# ==== end fzf ==== +EOF +fi + +echo "✅ Done." +echo "➡ Open a NEW terminal or run: exec zsh" + |
