Переход на использование zinit

This commit is contained in:
Andrei Astafev 2022-12-17 19:17:36 +03:00
parent 723cf0b917
commit 6b44017c88
15 changed files with 417 additions and 218 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
*.post.zsh *.post.zsh
*.pre.zsh *.pre.zsh
*.user.zsh *.user.zsh
.zshenv.user
.zcalc_history .zcalc_history
.zcompdump* .zcompdump*
*.zwc *.zwc

365
.p10k.zsh

File diff suppressed because it is too large Load Diff

55
.zshenv
View File

@ -1,11 +1,64 @@
# Запрет чтения настроек из системного каталога /etc # Запрет чтения настроек из системного каталога /etc
unsetopt GLOBAL_RCS unsetopt GLOBAL_RCS
# Базовые каталоги # PATH {{{
# Ruby
if which ruby >/dev/null && which gem >/dev/null; then
path=("$(ruby -r rubygems -e 'puts Gem.user_dir')/bin" $path)
fi
# Поиск в домашнем каталоге
path=("$HOME/bin" "$HOME/.local/bin" $path)
# Удалить дубликаты в массиве
typeset -aU path
# }}}
# Базовые каталоги {{{
export XDG_CONFIG_HOME="$HOME/.config" export XDG_CONFIG_HOME="$HOME/.config"
export XDG_CACHE_HOME="$HOME/.cache" export XDG_CACHE_HOME="$HOME/.cache"
export XDG_DATA_HOME="$HOME/.local/share" export XDG_DATA_HOME="$HOME/.local/share"
export XDG_STATE_HOME="$HOME/.local/state"
# }}}
export ZSH_CACHE_DIR="$XDG_CACHE_HOME/zsh" export ZSH_CACHE_DIR="$XDG_CACHE_HOME/zsh"
export ZSH_COMPDUMP="$ZSH_CACHE_DIR/zcompdump-${HOST/.*/}-$ZSH_VERSION" export ZSH_COMPDUMP="$ZSH_CACHE_DIR/zcompdump-${HOST/.*/}-$ZSH_VERSION"
# Отключаем некоторые плагины, если запуск в качестве подоболочки mc
# Bug: https://midnight-commander.org/ticket/4253
[ "$(ps -p $PPID -o cmd=)" = "mc" ] && ZSH_MC_SUBSHELL=1
# GnuPG
export GNUPGHOME="$XDG_CONFIG_HOME/gnupg"
# ASKPASS {{{
if [ -n ${DISPLAY+set} ]; then
if command -v /usr/lib/openssh/gnome-ssh-askpass 2>&1 >/dev/null; then
export SSH_ASKPASS=/usr/lib/openssh/gnome-ssh-askpass
elif command -v /usr/bin/lxqt-openssh-askpass 2>&1 >/dev/null; then
export SSH_ASKPASS=/usr/bin/lxqt-openssh-askpass
elif command -v /usr/bin/ssh-askpass 2>&1 >/dev/null; then
export SSH_ASKPASS=/usr/bin/ssh-askpass
fi
fi
# }}}
# Настройка uncrustify
export UNCRUSTIFY_CONFIG="${XDG_CONFIG_HOME}/uncrustify/uncrustify.cfg"
[ ! -r "${UNCRUSTIFY_CONFIG}" ] && unset UNCRUSTIFY_CONFIG
# Настройка Intel Studio
if [ -n ${ENABLE_INTEL_STUDIO+set} ]; then
#export COMPILERVARS_ARCHITECTURE=intel64
#export COMPILERVARS_PLATFORM=linux
INTEL_VARS=( /opt/intel/oneapi/advisor/latest/advixe-vars.sh
/opt/intel/oneapi/compiler/latest/env/vars.sh
/opt/intel/vtune_profiler/vtune-vars.sh )
for f in ${INTEL_VARS[*]}; do
[ -r "$f" ] && source "$f" > /dev/null
done
fi
[ -r "$ZDOTDIR/.zshenv.user" ] && source "$ZDOTDIR/.zshenv.user"

22
.zshrc
View File

@ -3,28 +3,24 @@
for S in \ for S in \
05-start \ 05-start \
15-env \ 15-options \
25-history \ 25-history \
35-options \ 41-zinit \
42-zcomet \ 45-plugins \
45-prompt \
48-plugins \
55-agents \ 55-agents \
65-scripts \ 65-scripts \
75-aliases \ 75-aliases \
85-completion \ 85-completion \
88-prompt \
95-finish 95-finish
do do
N="${S//[0-9\-]/}" N="${S//[0-9\-]/}"
[ -e "$ZDOTDIR/$S.pre.zsh" ] && source "$ZDOTDIR/$S.pre.zsh" [ -r "$ZDOTDIR/$S.pre.zsh" ] && source "$ZDOTDIR/$S.pre.zsh" || true
[ -e "$ZDOTDIR/$S.zsh" ] && source "$ZDOTDIR/$S.zsh" [ -r "$ZDOTDIR/$S.zsh" ] && source "$ZDOTDIR/$S.zsh" || true
[ -e "$ZDOTDIR/$S.user.zsh" ] && source "$ZDOTDIR/$S.user.zsh" [ -r "$ZDOTDIR/$S.user.zsh" ] && source "$ZDOTDIR/$S.user.zsh" || true
[ -e "$ZDOTDIR/$N.user.zsh" ] && source "$ZDOTDIR/$N.user.zsh" [ -r "$ZDOTDIR/$N.user.zsh" ] && source "$ZDOTDIR/$N.user.zsh" || true
[ -e "$ZDOTDIR/$S.post.zsh" ] && source "$ZDOTDIR/$S.post.zsh" [ -r "$ZDOTDIR/$S.post.zsh" ] && source "$ZDOTDIR/$S.post.zsh" || true
done done
# To customize prompt, run `p10k configure` or edit ~/.config/zsh/.p10k.zsh.
[[ ! -f "${ZDOTDIR}/.p10k.zsh" ]] || source "${ZDOTDIR}/.p10k.zsh"
# zprof # zprof

View File

@ -1 +1,9 @@
# Enable Powerlevel10k instant prompt.
# Should stay close to the top of ~/.config/zsh/.zshrc.
# Initialization code that may require console input
# (password prompts, [y/n] confirmations, etc.)
# must go above this block; everything else may go below.
if [ -r "${XDG_CACHE_HOME}/p10k-instant-prompt-${(%):-%n}.zsh" ]; then
source "${XDG_CACHE_HOME}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

25
15-options.zsh Normal file
View File

@ -0,0 +1,25 @@
setopt AUTO_PUSHD # Push the current directory visited on the stack.
setopt PUSHD_IGNORE_DUPS # Do not store duplicates in the stack.
setopt PUSHD_SILENT # Do not print the directory stack after pushd or popd.
autoload -Uz allopt zed zmv zcalc colors is-at-least
colors
zmodload zsh/terminfo
autoload -Uz edit-command-line
zle -N edit-command-line
autoload -Uz select-word-style
select-word-style shell
if is-at-least 5.1; then
autoload -Uz bracketed-paste-magic
zle -N bracketed-paste bracketed-paste-magic
fi
autoload -Uz url-quote-magic
zle -N self-insert url-quote-magic
# Подсветка вывода основных команд
[[ -r /etc/grc.zsh ]] && source /etc/grc.zsh

16
41-zinit.zsh Normal file
View File

@ -0,0 +1,16 @@
declare -A ZINIT
ZINIT[HOME_DIR]="$ZSH_CACHE_DIR/zinit"
ZINIT[PLUGINS_DIR]="$ZSH_CACHE_DIR/plugins"
ZINIT[SNIPPETS_DIR]="$ZSH_CACHE_DIR/snippets"
ZINIT[ZCOMPDUMP_PATH]="$ZSH_CACHE_DIR/zcompdump"
ZPFX="$ZSH_CACHE_DIR/polaris"
if [ ! -d "$ZINIT[HOME_DIR]" ]; then
git clone https://github.com/zdharma-continuum/zinit "$ZINIT[HOME_DIR]"
zcompile "$ZINIT[HOME_DIR]/zinit.zsh"
fi
source "$ZINIT[HOME_DIR]/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit

65
45-plugins.zsh Normal file
View File

@ -0,0 +1,65 @@
zinit load willghatch/zsh-saneopt
zinit load mafredri/zsh-async
export ZSHZ_CASE=smart
export ZSHZ_DATA="${ZSH_CACHE_DIR}/z"
zinit light agkozak/zsh-z
if [ "$(id -u)" != "0" ] && [ -n ${DISPLAY+set} ]; then
zstyle ':notify:*' expire-time 5000
zstyle ':notify:*' command-complete-timeout 20
zstyle ':notify:*' enable-on-ssh yes
zinit light marzocchi/zsh-notify
fi
zinit snippet OMZL::key-bindings.zsh
zinit snippet OMZP::autojump
zinit snippet OMZP::command-not-found
zinit snippet OMZP::common-aliases
zinit snippet OMZP::debian
zinit snippet OMZP::fzf
zinit snippet OMZP::isodate
zinit snippet OMZP::mosh
zinit snippet OMZP::nmap
zinit snippet OMZP::pre-commit
zinit snippet OMZP::rsync
zinit snippet OMZP::vscode
zinit snippet OMZP::web-search
zinit load brymck/print-alias
zinit ice lucid wait'0'
zinit light joshskidmore/zsh-fzf-history-search
if command -v git > /dev/null 2>&1; then
GIT_AUTO_FETCH_INTERVAL=3600
zinit snippet OMZP::git
zinit snippet OMZP::gitfast
zinit snippet OMZP::git-extras
zinit snippet OMZP::github
[ -z ${SSH_CONNECTION+set} ] && zinit snippet OMZP::git-auto-fetch
zinit load paulirish/git-open
fi
if command -v psql > /dev/null 2>&1; then
zinit snippet OMZP::postgres
fi
if command -v sudo > /dev/null 2>&1; then
zinit snippet OMZP::sudo
fi
if command -v systemctl > /dev/null 2>&1; then
zinit snippet OMZP::systemd
fi
if command -v vim > /dev/null 2>&1; then
zinit snippet OMZP::vim-interaction
fi
if command -v tmux > /dev/null 2>&1; then
zstyle ':prezto:module:tmux:auto-start' local 'no'
zstyle ':prezto:module:tmux:auto-start' remote 'no'
zstyle ':prezto:module:tmux:session' name "$(hostname)"
zinit ice pick'init.zsh'
zinit light laggardkernel/zsh-tmux
zinit light amyreese/zsh-titles
fi
if command -v kitty > /dev/null 2>&1; then
zinit load redxtech/zsh-kitty
fi

View File

@ -6,17 +6,17 @@
# zstyle :omz:plugins:ssh-agent agent-forwarding on # zstyle :omz:plugins:ssh-agent agent-forwarding on
# zstyle :omz:plugins:ssh-agent identities id_rsa # zstyle :omz:plugins:ssh-agent identities id_rsa
# zstyle :omz:plugins:ssh-agent lifetime 10h # zstyle :omz:plugins:ssh-agent lifetime 10h
# zcomet load ohmyzsh plugins/ssh-agent # zinit snippet OMZP::ssh-agent
## ##
# GPG agent # GPG agent
## ##
# zcomet load ohmyzsh plugins/gpg-agent # zinit snippet OMZP::gpg-agent
## ##
# Keychain # Keychain
## ##
# zstyle :omz:plugins:keychain identities id_rsa 01234567 # zstyle :omz:plugins:keychain identities id_rsa 01234567
# zstyle :omz:plugins:keychain options --quiet --inherit local-once --noask --nocolor --quick # zstyle :omz:plugins:keychain options --quiet --inherit any-once --noask --nocolor --gpg2 --absolute --dir ~/.cache/keychain
# zstyle :omz:plugins:keychain agents gpg,ssh # zstyle :omz:plugins:keychain agents gpg,ssh
# zsh-defer zcomet load ohmyzsh plugins/keychain # zinit snippet OMZP::keychain

View File

@ -1,9 +1,6 @@
# Обновление конфигурации zsh, менджера zcomet и плагинов # Обновление конфигурации zsh, менеджера zinit и плагинов
zu() { zu() {
git -C ~/.config/zsh pull && zcomet self-update && zcomet update git -C "${ZDOTDIR}" pull && zinit update --parallel
if [[ -f "${ZCOMET_DIR}/prompt/powerlevel10k/powerlevel10k.zsh-theme" ]]; then
command git -C "${ZCOMET_DIR}/prompt/powerlevel10k" pull
fi
exec zsh exec zsh
} }

View File

@ -34,10 +34,10 @@ if command -v youtube-dl > /dev/null 2>&1; then
fi fi
# feh # feh
command -v feg > /dev/null 2>&1 && alias feh="feh --cache-size 256 --version-sort --sort filename --image-bg black" command -v feh > /dev/null 2>&1 && alias feh="feh --cache-size 256 --version-sort --sort filename --image-bg black"
# Замена шрифта у заголовка окна в i3 при использовании ssh или mosh # Замена шрифта у заголовка окна в i3 при использовании ssh или mosh
if [ ! -z ${DISPLAY+x} ] ; then if [ -n ${DISPLAY+set} ] ; then
if command -v i3-msg >/dev/null 2>&1 ; then if command -v i3-msg >/dev/null 2>&1 ; then
i3-mosh () { i3-mosh () {
i3-msg -q title_format "<span foreground='#AAAAFF' font-weight='bold'>%title</span>" i3-msg -q title_format "<span foreground='#AAAAFF' font-weight='bold'>%title</span>"
@ -63,6 +63,8 @@ alias gsur="git submodule update --recursive --init --remote"
command -v lazygit > /dev/null 2>&1 && alias lg=lazygit command -v lazygit > /dev/null 2>&1 && alias lg=lazygit
# Фильтры (H,T,G,L определены в common-aliases) # Фильтры (H,T,G,L определены в common-aliases)
alias -g N1='1>/dev/null'
alias -g N2='2>/dev/null'
alias -g NN='&>/dev/null' alias -g NN='&>/dev/null'
alias -g S='| sort' alias -g S='| sort'
@ -77,4 +79,6 @@ alias -g X0='| xargs -0'
alias -g XS='| sort | xargs' alias -g XS='| sort | xargs'
alias -g XS0='| sort -z | xargs -0' alias -g XS0='| sort -z | xargs -0'
alias -g Z='| fzf'
audio-join() ffmpeg -i "concat:${(j:|:)@[2,-1]}" -acodec copy $1 audio-join() ffmpeg -i "concat:${(j:|:)@[2,-1]}" -acodec copy $1

View File

@ -23,10 +23,15 @@ zstyle ':completion:*:(ssh|scp|rsync):*:hosts-host' ignored-patterns '*.*' loo
zstyle ':completion:*:(ssh|scp|rsync):*:hosts-domain' ignored-patterns '<->.<->.<->.<->' '^*.*' '*@*' zstyle ':completion:*:(ssh|scp|rsync):*:hosts-domain' ignored-patterns '<->.<->.<->.<->' '^*.*' '*@*'
zstyle ':completion:*:(ssh|scp|rsync):*:hosts-ipaddr' ignored-patterns '^<->.<->.<->.<->' '127.0.0.<->' zstyle ':completion:*:(ssh|scp|rsync):*:hosts-ipaddr' ignored-patterns '^<->.<->.<->.<->' '127.0.0.<->'
zcomet load zsh-users/zsh-completions if is-at-least 5.7; then
zstyle ':autocomplete:*' min-input 2
# Вызов в этом месте и в таком порядке zstyle ':autocomplete:*' fzf-completion yes
zsh-defer zcomet load zsh-users/zsh-autosuggestions zinit light marlonrichert/zsh-autocomplete
# zsh-defer zcomet load zsh-users/zsh-syntax-highlighting else
zsh-defer zcomet load zsh-users/zsh-history-substring-search zinit wait lucid light-mode for \
atinit"zicompinit; zicdreplay" zdharma-continuum/fast-syntax-highlighting \
atload"_zsh_autosuggest_start" zsh-users/zsh-autosuggestions \
blockf atpull'zinit creinstall -q .' zsh-users/zsh-completions
zinit load zsh-users/zsh-history-substring-search
fi

9
88-prompt.zsh Normal file
View File

@ -0,0 +1,9 @@
if is-at-least 5.3; then
zinit ice depth"1" # git clone depth
zinit light romkatv/powerlevel10k
# To customize prompt, run `p10k configure` or edit ~/.config/zsh/.p10k.zsh.
[[ ! -f $ZDOTDIR/.p10k.zsh ]] || source $ZDOTDIR/.p10k.zsh
else
zinit load agkozak/agkozak-zsh-prompt
fi

View File

@ -1,2 +0,0 @@
zcomet compinit

View File

@ -27,17 +27,12 @@ git clone https://git.246060.ru/f1x1t/zshrc ~/.config/zsh
# Базовая настройка # Базовая настройка
С правами суперпользователя открыть файл `/etc/zsh/zshenv` Создать файл `$HOME/.zshenv` со следующим содержимым:
в редакторе командой
```sh ```sh
sudo ${EDITOR:-mcedit} /etc/zsh/zshenv # Загрузка конфигурации из каталога $ZDOTDIR
``` export ZDOTDIR=$HOME/.config/zsh
source $ZDOTDIR/.zshenv
и добавить строку
```sh
[[ -z "$ZDOTDIR" ]] && export ZDOTDIR="$HOME/.config/zsh"
``` ```
Установить интерпретатор Zsh по умолчанию для пользователя `username`. Установить интерпретатор Zsh по умолчанию для пользователя `username`.
@ -60,7 +55,7 @@ cp ~/.config/zsh/55-agents.zsh ~/.config/zsh/55-agents.user.zsh
Раскомментировать в файле ` ~/.config/zsh/55-agents.user.zsh` строки: Раскомментировать в файле ` ~/.config/zsh/55-agents.user.zsh` строки:
```sh ```sh
# zcomet load ohmyzsh plugins/gpg-agent # zinit snippet OMZP::gpg-agent
``` ```
Пример файла настройки GPG агента `~/.config/gnupg/gpg-agent.conf`: Пример файла настройки GPG агента `~/.config/gnupg/gpg-agent.conf`:
@ -87,7 +82,7 @@ pinentry-program /usr/bin/pinentry-qt
# zstyle :omz:plugins:ssh-agent agent-forwarding on # zstyle :omz:plugins:ssh-agent agent-forwarding on
# zstyle :omz:plugins:ssh-agent identities id_rsa # zstyle :omz:plugins:ssh-agent identities id_rsa
# zstyle :omz:plugins:ssh-agent lifetime 10h # zstyle :omz:plugins:ssh-agent lifetime 10h
# zcomet load ohmyzsh plugins/ssh-agent # zinit snippet OMZP::ssh-agent
``` ```
Добавить в конец файла `~/.ssh/config` правило для разрешения агенту сохранять ключи: Добавить в конец файла `~/.ssh/config` правило для разрешения агенту сохранять ключи:
@ -115,7 +110,7 @@ use-ssh-agent
# zstyle :omz:plugins:keychain identities id_rsa 01234567 # zstyle :omz:plugins:keychain identities id_rsa 01234567
# zstyle :omz:plugins:keychain options --quiet --inherit local-once --noask --nocolor --quick # zstyle :omz:plugins:keychain options --quiet --inherit local-once --noask --nocolor --quick
# zstyle :omz:plugins:keychain agents gpg,ssh # zstyle :omz:plugins:keychain agents gpg,ssh
# zcomet load ohmyzsh plugins/keychain # zinit snippet OMZP::keychain
``` ```
Отредактировать файлы настроек для агента GPG и SSH, как это описано в разделах выше. Отредактировать файлы настроек для агента GPG и SSH, как это описано в разделах выше.
@ -124,12 +119,12 @@ use-ssh-agent
## Инициализация ## Инициализация
После редактирования файлов настройки запустить `zsh`. Автоматически будет загружен После редактирования файлов настройки запустить `zsh`. Автоматически будет загружен
менеджер [zcomet](https://github.com/agkozak/zcomet) и необходимые плагины. менеджер [zinit](https://github.com/zdharma-continuum/zinit) и необходимые плагины.
## Обновление ## Обновление
Обновление `zcomet` и плагинов: Обновление `zinit` и плагинов:
```sh ```sh
zu zu