From ba6c92a2ceebd2771e64b994f51f2bd0ec8bf0fa Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Tue, 13 Jul 2021 16:17:09 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D1=85=D0=BE=D0=B4=20?= =?UTF-8?q?=D0=BD=D0=B0=20zdharma/zinit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .zshrc | 3 ++- agents.zsh | 6 ++--- aliases.zsh | 3 +++ compinit.zsh | 27 ++++++++++++++++++++++ env.zsh | 10 ++++++-- options.zsh | 28 ++++++++--------------- plugins.zsh | 64 +++++++++++++++++++++++++++++++--------------------- prompt.zsh | 35 ++++++++++++++-------------- 8 files changed, 108 insertions(+), 68 deletions(-) create mode 100644 compinit.zsh diff --git a/.zshrc b/.zshrc index ded8825..cd5bfb3 100644 --- a/.zshrc +++ b/.zshrc @@ -21,6 +21,7 @@ source $ZDOTDIR/prompt.zsh source $ZDOTDIR/aliases.zsh [ -e $ZDOTDIR/aliases.user.zsh ] && source $ZDOTDIR/aliases.user.zsh -zplug load +source $ZDOTDIR/compinit.zsh +[ -e $ZDOTDIR/compinit.user.zsh ] && source $ZDOTDIR/compinit.user.zsh true diff --git a/agents.zsh b/agents.zsh index cf60fd7..9e07255 100644 --- a/agents.zsh +++ b/agents.zsh @@ -6,12 +6,12 @@ # zstyle :omz:plugins:ssh-agent agent-forwarding on # zstyle :omz:plugins:ssh-agent identities id_rsa # zstyle :omz:plugins:ssh-agent lifetime 10h -# zplug "plugins/ssh-agent", from:oh-my-zsh +# zinit snippet OMZP::ssh-agent ## # GPG agent ## -# zplug "plugins/gpg-agent", from:oh-my-zsh +# zinit snippet OMZP::gpg-agent ## # Keychain @@ -19,5 +19,5 @@ # zstyle :omz:plugins:keychain identities id_rsa 01234567 # zstyle :omz:plugins:keychain options --quiet --inherit local-once --noask --nocolor --quick # zstyle :omz:plugins:keychain agents gpg,ssh -# zplug "plugins/keychain", from:oh-my-zsh +# zinit snippet OMZP::keychain diff --git a/aliases.zsh b/aliases.zsh index 14fe3fc..4f07a93 100644 --- a/aliases.zsh +++ b/aliases.zsh @@ -22,6 +22,9 @@ apts() { fi } +# VIM +alias gvim='gvim --remote-silent' + # Youtube YDL="$HOME/bin/youtube-dl" [ ! -x "$YDL" ] && YDL="$(which youtube-dl)" diff --git a/compinit.zsh b/compinit.zsh new file mode 100644 index 0000000..39e38fc --- /dev/null +++ b/compinit.zsh @@ -0,0 +1,27 @@ +typeset -i _compinit_updated_at=$(date +'%j' -r $ZINIT[ZCOMPDUMP_PATH] 2>/dev/null || stat -f '%Sm' -t '%j' $ZINIT[ZCOMPDUMP_PATH] 2>/dev/null) +if [ $(date +'%j') != $_compinit_updated_at ]; then + ZINIT[COMPINIT_OPTS]="-i" +else + ZINIT[COMPINIT_OPTS]="-C -i" +fi +unset _compinit_updated_at + +zinit wait lucid for \ + atinit"zpcompinit; zpcdreplay" \ + zdharma/fast-syntax-highlighting \ + atload"!_zsh_autosuggest_start" \ + zsh-users/zsh-autosuggestions \ + blockf \ + zsh-users/zsh-completions + +zmodload -i zsh/complist + +zstyle ':completion:*:processes' command 'ps -ax' +zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;32' +zstyle ':completion:*:*:kill:*' menu yes select +zstyle ':completion:*:kill:*' force-list always + +zstyle ':completion:*:processes-names' command 'ps -e -o comm=' +zstyle ':completion:*:*:killall:*' menu yes select +zstyle ':completion:*:killall:*' force-list always + diff --git a/env.zsh b/env.zsh index 97baa54..0cdfa9a 100644 --- a/env.zsh +++ b/env.zsh @@ -2,9 +2,15 @@ export XDG_CONFIG_HOME=$HOME/.config export XDG_CACHE_HOME=$HOME/.cache export XDG_DATA_HOME=$HOME/.local/share -export ZPLUG_HOME=$XDG_CACHE_HOME/zplug -export PATH=$HOME/bin:$HOME/.local/bin:$PATH +declare -A ZINIT +ZINIT[HOME_DIR]=$XDG_CACHE_HOME/zsh/zinit +ZINIT[PLUGINS_DIR]=$XDG_CACHE_HOME/zsh/plugins +ZINIT[SNIPPETS_DIR]=$XDG_CACHE_HOME/zsh/snippets +ZINIT[ZCOMPDUMP_PATH]=$XDG_CACHE_HOME/zsh/zcompdump +ZPFX=$XDG_CACHE_HOME/zsh/polaris + +export PATH=$HOME/bin:$HOME/.local/bin:$PATH # Удалить дубликаты в PATH typeset -U PATH diff --git a/options.zsh b/options.zsh index 24bfe4a..30680e3 100644 --- a/options.zsh +++ b/options.zsh @@ -2,25 +2,15 @@ # apt-get install autojump [[ -s /usr/share/autojump/autojump.sh ]] && source /usr/share/autojump/autojump.sh -# Автодополнение -autoload -Uz compinit -autoload zmv +autoload -Uz allopt zed zmv zcalc colors +colors -typeset -i updated_at=$(date +'%j' -r ~/.zcompdump 2>/dev/null || stat -f '%Sm' -t '%j' ~/.zcompdump 2>/dev/null) -if [ $(date +'%j') != $updated_at ]; then - compinit -i -else - compinit -C -i -fi +autoload -Uz edit-command-line +zle -N edit-command-line +#bindkey -M vicmd v edit-command-line -zmodload -i zsh/complist - -zstyle ':completion:*:processes' command 'ps -ax' -zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;32' -zstyle ':completion:*:*:kill:*' menu yes select -zstyle ':completion:*:kill:*' force-list always - -zstyle ':completion:*:processes-names' command 'ps -e -o comm=' -zstyle ':completion:*:*:killall:*' menu yes select -zstyle ':completion:*:killall:*' force-list always +autoload -Uz select-word-style +select-word-style shell +autoload -Uz url-quote-magic +zle -N self-insert url-quote-magic diff --git a/plugins.zsh b/plugins.zsh index 2ffcd60..556e825 100644 --- a/plugins.zsh +++ b/plugins.zsh @@ -1,35 +1,35 @@ -# Менеджер плагинов zplug -if [ ! -d $ZPLUG_HOME ]; then - git clone https://github.com/zplug/zplug $ZPLUG_HOME +# Менеджер плагинов zinit +if [ ! -d $ZINIT[HOME_DIR] ]; then + git clone https://github.com/zdharma/zinit $ZINIT[HOME_DIR] + zcompile $ZINIT[HOME_DIR]/zinit.zsh fi -source $ZPLUG_HOME/init.zsh +source $ZINIT[HOME_DIR]/zinit.zsh +autoload -Uz _zinit +(( ${+_comps} )) && _comps[zinit]=_zinit # Плагины -zplug "zdharma/fast-syntax-highlighting", defer:2 +zinit load willghatch/zsh-saneopt +zinit load mafredri/zsh-async +zinit load zsh-users/zsh-history-substring-search -# Make sure to use double quotes -zplug "zsh-users/zsh-history-substring-search" - -zplug "zsh-users/zsh-autosuggestions" -zplug "zsh-users/zsh-history-substring-search" -zplug "zsh-users/zsh-completions" -zplug "rupa/z" +zinit load rupa/z if [[ "$DISPLAY" != '' ]] && command -v xdotool > /dev/null 2>&1 && command -v wmctrl > /dev/null 2>&1; then - zplug "marzocchi/zsh-notify" - zstyle ':notify:*' expire-time 6000 + zinit load marzocchi/zsh-notify + zstyle ':notify:*' expire-time 5000 zstyle ':notify:*' command-complete-timeout 20 + zstyle ':notify:*' enable-on-ssh yes fi if command -v peco > /dev/null 2>&1; then - zplug "jimeh/zsh-peco-history" + zinit load jimeh/zsh-peco-history fi -zplug "plugins/command-not-found", from:oh-my-zsh -zplug "plugins/common-aliases", from:oh-my-zsh -zplug "plugins/debian", from:oh-my-zsh +zinit snippet OMZP::command-not-found +zinit snippet OMZP::common-aliases +zinit snippet OMZP::debian if command -v fzf > /dev/null 2>&1; then export DISABLE_FZF_KEY_BINDINGS=true - zplug "plugins/fzf", from:oh-my-zsh + zinit snippet OMZP::fzf # fzf if [ -e /usr/share/doc/fzf/examples/key-bindings.zsh ]; then . /usr/share/doc/fzf/examples/key-bindings.zsh @@ -39,14 +39,26 @@ if command -v fzf > /dev/null 2>&1; then fi fi if command -v git > /dev/null 2>&1; then - zplug "plugins/git", from:oh-my-zsh + zinit snippet OMZP::git + zinit load paulirish/git-open + zinit lucid wait'2' for \ + as"program" pick"$ZPFX/bin/git-*" \ + src"etc/git-extras-completion.zsh" make"PREFIX=$ZPFX" tj/git-extras \ + as"program" make"PREFIX=$ZPFX install" Fakerr/git-recall \ + as"program" load davidosomething/git-my fi if command -v psql > /dev/null 2>&1; then - zplug "plugins/postgres", from:oh-my-zsh + zinit snippet OMZP::postgres fi -zplug "plugins/sudo", from:oh-my-zsh -zplug "plugins/systemd", from:oh-my-zsh -zplug "plugins/vim-interaction", from:oh-my-zsh -zplug "plugins/web-search", from:oh-my-zsh +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 +zinit snippet OMZP::web-search -zplug "djui/alias-tips" +zinit load djui/alias-tips diff --git a/prompt.zsh b/prompt.zsh index 2a0ed4c..ac2f838 100644 --- a/prompt.zsh +++ b/prompt.zsh @@ -1,17 +1,17 @@ # Theme # Install powerline font SPACESHIP_PROMPT_ORDER=( - user # Username section - dir # Current directory section - host # Hostname section - git # Git section (git_branch + git_status) - hg # Mercurial section (hg_branch + hg_status) - exec_time # Execution time - line_sep # Line break - vi_mode # Vi-mode indicator - jobs # Background jobs indicator - exit_code # Exit code section - char # Prompt character + user # Username section + dir # Current directory section + host # Hostname section + git # Git section (git_branch + git_status) + hg # Mercurial section (hg_branch + hg_status) + exec_time # Execution time + line_sep # Line break + vi_mode # Vi-mode indicator + jobs # Background jobs indicator + exit_code # Exit code section + char # Prompt character ) @@ -22,13 +22,14 @@ SPACESHIP_CHAR_SUFFIX=" " # Simplify prompt if we're using Hyper if [[ "$TERM_PROGRAM" == "Hyper" ]]; then - SPACESHIP_PROMPT_SEPARATE_LINE=false - SPACESHIP_DIR_SHOW=false - SPACESHIP_GIT_BRANCH_SHOW=false + SPACESHIP_PROMPT_SEPARATE_LINE=false + SPACESHIP_DIR_SHOW=false + SPACESHIP_GIT_BRANCH_SHOW=false fi -if __zplug::base::base::zsh_version 5.2; then - zplug "denysdovhan/spaceship-prompt" +autoload is-at-least +if is-at-least "5.2" "$ZSH_VERSION"; then + zinit load "denysdovhan/spaceship-prompt" else - zplug "nojhan/liquidprompt" + zinit load "nojhan/liquidprompt" fi