All presents

Fuzzy Tab

Type fragments, press Tab, and execute full commands from fuzzy history in zsh.

Fuzzy Tab

A tiny zsh upgrade with a big UX payoff:

  • Type a fragment (for example: tui)
  • Press Tab
  • Your shell expands to the best fuzzy history match (for example: openclaw tui)
  • Press Enter

It feels like command-line autocomplete, but based on intent, not just prefix matches.


Why this exists

Classic history search is usually Ctrl-R and modal.

Fuzzy Tab makes it default behavior on Tab:

  • fast muscle memory
  • no context switch
  • works with mid-command fragments

zsh config

# Fuzzy history expansion on TAB
_fuzzy_history_expand() {
  emulate -L zsh
  setopt localoptions pipefail no_aliases

  local query="$LBUFFER"

  # Empty buffer: keep normal completion behavior
  if [[ -z "$query" ]]; then
    zle expand-or-complete
    return
  fi

  local selected
  selected=$(fc -rl 1 \
    | sed 's/^[[:space:]]*[0-9][0-9]*[[:space:]]*//' \
    | awk '!seen[$0]++' \
    | fzf --scheme=history --filter "$query" 2>/dev/null \
    | head -n 1)

  if [[ -n "$selected" ]]; then
    BUFFER="$selected"
    CURSOR=${#BUFFER}
  else
    zle expand-or-complete
  fi
}

zle -N fuzzy-history-expand _fuzzy_history_expand
bindkey '^I' fuzzy-history-expand

Notes

  • Requires fzf
  • If no fuzzy match exists, Tab falls back to normal completion
  • Great with zsh-autosuggestions (prefix ghost text) + Fuzzy Tab (intent recall)

That’s it. One small widget, much faster shell flow.