Рефакторинг

This commit is contained in:
Andrei Astafev 2022-12-23 11:39:49 +03:00
parent 01f900a450
commit 020da06b8a
8 changed files with 55 additions and 69 deletions

7
.zshrc
View File

@ -11,10 +11,11 @@ for S in \
42-zinit \
45-plugins \
55-agents \
65-scripts \
75-aliases \
62-scripts \
68-aliases \
72-widgets \
78-keybindings \
82-completion \
85-keybindings \
88-prompt \
95-finish
do

View File

@ -55,13 +55,9 @@ if command -v fzf > /dev/null 2>&1; then
zinit snippet https://github.com/junegunn/fzf/blob/master/shell/completion.zsh
zinit snippet https://github.com/junegunn/fzf/blob/master/shell/key-bindings.zsh
zinit ice lucid wait'0' lucid
zinit light joshskidmore/zsh-fzf-history-search
fi
fi
zinit light zdharma-continuum/zsh-navigation-tools
if command -v git > /dev/null 2>&1; then
GIT_AUTO_FETCH_INTERVAL=3600
zinit snippet OMZL::git.zsh

45
72-widgets.zsh Normal file
View File

@ -0,0 +1,45 @@
# shellcheck shell=bash
# vim: ft=sh
# Navi
if command -v navi > /dev/null 2>&1; then
zinit snippet https://github.com/denisidoro/navi/blob/master/shell/navi.plugin.zsh
function magic-ctrl-g {
if ! (( $#BUFFER )) && [[ "$CONTEXT" == start ]]; then _navi_widget; fi
}
zle -N magic-ctrl-g
bindkey '^G' magic-ctrl-g
fi
# FZF #{{{
if command -v fzf > /dev/null 2>&1; then
function magic-ctrl-f {
if ! (( $#BUFFER )) && [[ "$CONTEXT" == start ]]; then fzf-file-widget; fi
}
zle -N magic-ctrl-f
bindkey '^F' magic-ctrl-f
zinit ice wait'1' lucid light-mode depth'1' \
atload"bindkey '^H' fzf-history; \
bindkey '^Z' fzf-kill-proc-by-list"
zinit light amaya382/zsh-fzf-widgets
ZSH_FZF_PASTE_KEY=enter
ZSH_FZF_EXEC_KEY=ctrl-r
fi
#}}}
zinit wait'1' lucid light-mode depth'1' for \
atload"bindkey '^[[A' history-substring-search-up; \
bindkey '^[[B' history-substring-search-down" \
zsh-users/zsh-history-substring-search
[ "$(lsb_release -c -s)" = "orel" ] && ZSH_HISTORY_SEARCH_MULTI_WORD_MODE=1
[ -n "${SSH_CONNECTION}" ] && ZSH_HISTORY_SEARCH_MULTI_WORD_MODE=2
zstyle ':history-search-multi-word' page-size "$((LINES/2))"
zstyle ':plugin:history-search-multi-word' clear-on-cancel 'yes'
zinit ice \
if'[[ -z ${ZSH_HISTORY_SEARCH_MULTI_WORD_MODE+set} ]]' \
wait'1' lucid light-mode depth'1' \
atload"bindkey '^K' history-search-multi-word"
zinit light zdharma-continuum/history-search-multi-word

6
78-keybindings.zsh Normal file
View File

@ -0,0 +1,6 @@
# shellcheck shell=bash
# vim: ft=sh
# [Esc] [Esc]
bindkey '\e\e' send-break

View File

@ -37,32 +37,3 @@ zinit wait'0' lucid light-mode depth'1' for \
atload"!_zsh_autosuggest_start" \
zsh-users/zsh-autosuggestions
zinit wait'1' lucid light-mode depth'1' for \
atload"bindkey '^[[A' history-substring-search-up; \
bindkey '^[[B' history-substring-search-down" \
zsh-users/zsh-history-substring-search
[ "$(lsb_release -c -s)" = "orel" ] && ZSH_HISTORY_SEARCH_MULTI_WORD_MODE=1
[ -n "${SSH_CONNECTION}" ] && ZSH_HISTORY_SEARCH_MULTI_WORD_MODE=2
zstyle ':history-search-multi-word' page-size "$((LINES/2))"
zstyle ':plugin:history-search-multi-word' clear-on-cancel 'yes'
if [[ -z ${ZSH_HISTORY_SEARCH_MULTI_WORD_MODE+set} ]]; then
zinit wait'1' lucid light-mode depth'1' for \
atload"bindkey '^K' history-search-multi-word" \
zdharma-continuum/history-search-multi-word
#else
# function magic-ctrl-k {
# if ! (( $#BUFFER )) && [[ "$CONTEXT" == start ]]; then znt-history-widget; fi
# }
# zle -N magic-ctrl-k
# bindkey '^K' magic-ctrl-k
#elif [ ${ZSH_HISTORY_SEARCH_MULTI_WORD_MODE} = "1" ]; then
# zinit wait'2' lucid light-mode depth'1' for \
# atload"bindkey '^K' history-search-multi-word" \
# zdharma-continuum/history-search-multi-word
#elif [ ${ZSH_HISTORY_SEARCH_MULTI_WORD_MODE} = "2" ]; then
# zinit light zdharma-continuum/history-search-multi-word
# bindkey '^K' history-search-multi-word
fi

View File

@ -1,33 +0,0 @@
# shellcheck shell=bash
# vim: ft=sh
# [Esc] [Esc]
bindkey '\e\e' send-break
# Navi
if command -v navi > /dev/null 2>&1; then
zinit snippet https://github.com/denisidoro/navi/blob/master/shell/navi.plugin.zsh
function magic-ctrl-g {
if ! (( $#BUFFER )) && [[ "$CONTEXT" == start ]]; then _navi_widget; fi
}
zle -N magic-ctrl-g
bindkey '^G' magic-ctrl-g
fi
# FZF #{{{
function magic-ctrl-f {
if ! (( $#BUFFER )) && [[ "$CONTEXT" == start ]]; then fzf-file-widget; fi
}
zle -N magic-ctrl-f
bindkey '^F' magic-ctrl-f
bindkey "^[[A" fzf-history-widget # Up
bindkey "^[[B" fzf-history-widget # Down
bindkey "${terminfo[kcuu1]}" fzf-history-widget # Up
bindkey "${terminfo[kcud1]}" fzf-history-widget # Down
#}}}
function magic-ctrl-z {
if ! (( $#BUFFER )) && [[ "$CONTEXT" == start ]]; then znt-kill-widget; fi
}
zle -N magic-ctrl-z
bindkey '^Z' magic-ctrl-z