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,7 +29,14 @@
side-by-side = false
line-numbers = true
paging = always
pager = less --mouse -RFX
pager = less --mouse -R -+X -+F
file-decoration-style = none
file-style = "#2CB494" bold
hunk-header-decoration-style = none
line-numbers-left-style = "#2CB494"
line-numbers-right-style = "#2CB494"
plus-style = syntax "#0c2a24"
plus-emph-style = syntax "#164a3c"
[merge]
conflictstyle = zdiff3
@@ -80,5 +87,4 @@
m = commit --amend --verbose
st = stash
sa = stash apply
cc = copilot --continue

View File

@@ -5,6 +5,7 @@
typeset -gi _dots_prompt_cmd_start=0
typeset -gi _dots_prompt_cmd_ran=0
typeset -gi _dots_prompt_flashing=0
typeset -g _dots_prompt_symbol="λ"
typeset -g _dots_prompt_base=""
typeset -gA _dots_pc
@@ -183,7 +184,7 @@ _dots_git_async_start() {
_dots_build_dots_prompt_base() {
local dir_path="$(_dots_abbrev_path)"
local symbol="${_dots_pc[grey]}>${_dots_pc[reset]}"
local symbol="${_dots_pc[grey]}${_dots_prompt_symbol}${_dots_pc[reset]}"
(( EUID == 0 )) && symbol="${_dots_pc[orange]}${_dots_pc[bold]}#${_dots_pc[reset]}"
local line1="${_dots_pc[teal]}${dir_path}${_dots_pc[reset]}"
@@ -245,7 +246,7 @@ TRAPINT() {
_dots_prompt_flashing=1
local git_part=""
[[ -n "$_dots_git_info_result" ]] && git_part=" ${_dots_git_info_result}"
local flash_prompt=$'\n'"${_dots_pc[teal]}$(_dots_abbrev_path)${_dots_pc[reset]}${git_part}"$'\n'$'%{\e[48;2;248;140;20m\e[30m%}> %{\e[0m%}'
local flash_prompt=$'\n'"${_dots_pc[teal]}$(_dots_abbrev_path)${_dots_pc[reset]}${git_part}"$'\n'$'%{\e[48;2;248;140;20m\e[30m%}'"${_dots_prompt_symbol}"$' %{\e[0m%}'
PROMPT="$flash_prompt"
zle reset-prompt
zselect -t $PROMPT_FLASH_DELAY

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

View File

@@ -80,7 +80,7 @@ _dots_load_fzf() {
command -v fzf &>/dev/null || return
export FZF_DEFAULT_COMMAND='rg --files --hidden --glob "!.git"'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_DEFAULT_OPTS='--layout=reverse --height=40% --prompt="> " --info=inline-right --no-separator'
export FZF_DEFAULT_OPTS='--layout=reverse --height=40% --prompt="> " --info=inline-right --no-separator --margin=1,0,0,0'
# fzf --zsh requires v0.48+
if fzf --zsh &>/dev/null; then
source <(fzf --zsh)
@@ -103,6 +103,7 @@ _dots_load_fzf() {
_dots_load_zoxide() {
command -v zoxide &>/dev/null || return
export _ZO_FZF_OPTS="$FZF_DEFAULT_OPTS"
export _ZO_ECHO=0
eval "$(zoxide init zsh)"
}