# shellcheck shell=bash
# bindings.sh — readline key bindings and terminal tweaks, stow-friendly
# Repo path: bashrc/.config/bash/bindings.sh -> stows to ~/.config/bash/bindings.sh
# Sourced from ~/.bashrc via: source_shell_file "${XDG_CONFIG_HOME:-$HOME/.config}/bash/bindings.sh"
# Interactive shells only (Readline keymaps); no-op in non-interactive shells.

[[ $- != *i* ]] && return 0

# Fallback if sourced standalone (normally provided by .bashrc)
declare -F has_tool >/dev/null 2>&1 || has_tool() { command -v "$1" >/dev/null 2>&1; }

# Readline niceties
bind "set bell-style visible"
bind "set completion-ignore-case on"
bind "set show-all-if-ambiguous On"

# Disable XON/XOFF flow control (Ctrl+S/Ctrl+Q)
stty -ixon 2>/dev/null

# History search with the arrow keys
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'

# Ctrl-h deletes the previous word
bind '"\C-h": backward-kill-word'

# Zoxide quick jump
if has_tool zoxide; then
    bind '"\C-f":"zi\n"'
fi
