feat: prompt and widget

This commit is contained in:
2026-02-12 22:39:55 +00:00
parent 6cb7226273
commit 6b47b82651
4 changed files with 19 additions and 9 deletions

View File

@@ -29,10 +29,11 @@ _dots_load_keybindings() {
# Ctrl+E: edit file
_dots_edit_widget() {
local file
file="$({ rg --files --hidden --glob '!.git' 2>/dev/null || find . -type f -not -path '*/.git/*'; } \
file="$(rg --files --hidden --glob '!.git' 2>/dev/null \
| fzf --preview 'head -100 {}')" || { zle reset-prompt; return; }
${EDITOR:-vim} "$file" </dev/tty
BUFFER="${EDITOR:-vim} ${(q)file}"
zle reset-prompt
zle accept-line
}
zle -N _dots_edit_widget
bindkey '^E' _dots_edit_widget
@@ -77,14 +78,15 @@ _dots_load_keybindings() {
# Ctrl+F: find in files
_dots_find_in_files_widget() {
local selection
selection="$(rg --color=always --line-number --no-heading '' 2>/dev/null \
selection="$(rg --color=always --line-number --no-heading --hidden --glob '!.git' '' 2>/dev/null \
| fzf --ansi --delimiter=: \
--preview 'head -n $((({2}+30))) {1} | tail -n 60' \
--preview-window='right:60%')" || { zle reset-prompt; return; }
local file="${selection%%:*}"
local line="${${selection#*:}%%:*}"
${EDITOR:-vim} "+$line" "$file" </dev/tty
BUFFER="${EDITOR:-vim} +${line} ${(q)file}"
zle reset-prompt
zle accept-line
}
zle -N _dots_find_in_files_widget
bindkey '^F' _dots_find_in_files_widget