2
0
Files
dot/.zsh/plugin/ais.zsh

49 lines
882 B
Bash

# ais - ai selector (Rust)
# unified fuzzy finder replacing cdselect/fileselect/histselect
# requires: ais binary in PATH
if ! command -v ais &>/dev/null; then
return
fi
# C-j: directory selector
ais-cd() {
zle -I
local dir=$(ais cd </dev/tty 2>/dev/tty)
zle -R
if [[ -n "$dir" ]]; then
cd "$dir"
fi
zle reset-prompt
}
zle -N ais-cd
bindkey '^j' ais-cd
# C-f: file selector -> insert into buffer
ais-file() {
zle -I
local file=$(ais file </dev/tty 2>/dev/tty)
zle -R
if [[ -n "$file" ]]; then
BUFFER+="$file"
CURSOR=${#BUFFER}
fi
zle reset-prompt
}
zle -N ais-file
bindkey '^f' ais-file
# C-r: history selector -> insert into buffer
ais-hist() {
zle -I
local cmd=$(ais hist </dev/tty 2>/dev/tty)
zle -R
if [[ -n "$cmd" ]]; then
BUFFER="$cmd"
CURSOR=${#BUFFER}
fi
zle reset-prompt
}
zle -N ais-hist
bindkey '^r' ais-hist