From 8d03a2ed06984b0bfe4f90507f59a5b548c6b5b8 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Mon, 6 Dec 2021 00:42:07 +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=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20Oh=20My=20Zsh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .zshrc | 7 ++-- 12-functions.zsh | 8 ++++ 15-env.zsh | 24 +++++++---- 45-plugins.zsh | 70 -------------------------------- 65-prompt.zsh => 45-prompt.zsh | 9 +++- 55-agents.zsh | 8 ++-- 78-scripts.zsh => 65-scripts.zsh | 0 82-plugins.zsh | 63 ++++++++++++++++++++++++++++ 85-compinit.zsh | 19 ++------- 88-ohmyzsh.zsh | 12 ++++++ 95-finish.zsh | 3 -- README.md | 8 ++-- 12 files changed, 121 insertions(+), 110 deletions(-) create mode 100644 12-functions.zsh delete mode 100644 45-plugins.zsh rename 65-prompt.zsh => 45-prompt.zsh (73%) rename 78-scripts.zsh => 65-scripts.zsh (100%) create mode 100644 82-plugins.zsh create mode 100644 88-ohmyzsh.zsh diff --git a/.zshrc b/.zshrc index d3178c1..1203b42 100644 --- a/.zshrc +++ b/.zshrc @@ -3,12 +3,13 @@ for S in \ 15-env \ 25-history \ 35-options \ - 45-plugins \ + 45-prompt \ 55-agents \ - 65-prompt \ + 65-scripts \ 75-aliases \ - 78-scripts \ + 82-plugins \ 85-compinit \ + 88-ohmyzsh \ 95-finish do N="${S//[0-9\-]/}" diff --git a/12-functions.zsh b/12-functions.zsh new file mode 100644 index 0000000..233a737 --- /dev/null +++ b/12-functions.zsh @@ -0,0 +1,8 @@ +function add_custom_plugin() +{ + if [ ! -d "$ZSH_CUSTOM/plugins/$2" ]; then + git clone "$1" "$ZSH_CUSTOM/plugins/$2" + fi + plugins+=($2) +} + diff --git a/15-env.zsh b/15-env.zsh index 212c808..3f4841c 100644 --- a/15-env.zsh +++ b/15-env.zsh @@ -3,22 +3,17 @@ export XDG_CACHE_HOME="$HOME/.cache" export XDG_DATA_HOME="$HOME/.local/share" export ZSH_CACHE_DIR="$XDG_CACHE_HOME/zsh" -export ZSH_COMPDUMP="$ZSH_CACHE_DIR/completions/dump" -export ZGEN_SOURCE="$ZSH_CACHE_DIR" -export ZGEN_SOURCE_BIN="$ZSH_CACHE_DIR/plugins" -export ZGEN_DIR="$ZSH_CACHE_DIR/zgenom" +export ZSH="$ZSH_CACHE_DIR/ohmyzsh" +export ZSH_CUSTOM="$ZSH_CACHE_DIR/custom" +export ZSH_COMPDUMP="${ZSH_CACHE_DIR}/zcompdump-${HOST/.*/}-${ZSH_VERSION}" +plugins=() if ps $PPID | grep mc; then export ZSH_IS_SUBSHELL=1 fi -ZPFX=$ZGEN_DIR/polaris - -DISABLE_AUTO_UPDATE=true - # PATH for P in \ - "$HOME/.vim/plugged/vim-superman/bin" \ "$HOME/bin" \ "$HOME/.local/bin" do @@ -33,6 +28,17 @@ typeset -U PATH export GNUPGHOME="$XDG_CONFIG_HOME/gnupg" export SVDIR="$HOME/sv" +# ASKPASS +if [ ! -z ${DISPLAY+x} ]; 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 UNCRUSTIFY_CONFIG="${XDG_CONFIG_HOME}/uncrustify/default.cfg" [ -e "${UNCRUSTIFY_CONFIG}" ] && export UNCRUSTIFY_CONFIG diff --git a/45-plugins.zsh b/45-plugins.zsh deleted file mode 100644 index 8f39c64..0000000 --- a/45-plugins.zsh +++ /dev/null @@ -1,70 +0,0 @@ -# Менеджер плагинов zgenom -if [ ! -e "$ZGEN_DIR/zgenom.zsh" ]; then - git clone https://github.com/jandamm/zgenom "$ZGEN_DIR" -fi - -source "$ZGEN_DIR/zgenom.zsh" - -# -# Ohmyzsh -# -zgenom ohmyzsh - -# Плагины -zgenom load willghatch/zsh-saneopt -zgenom load mafredri/zsh-async -zgenom load djui/alias-tips - -zgenom load rupa/z -if [[ "$DISPLAY" != '' ]] && command -v xdotool > /dev/null 2>&1 && command -v wmctrl > /dev/null 2>&1; then - zgenom 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 - zgenom load jimeh/zsh-peco-history -fi - -zgenom ohmyzsh plugins/autojump -zgenom ohmyzsh plugins/command-not-found -zgenom ohmyzsh plugins/common-aliases -zgenom ohmyzsh plugins/debian -zgenom ohmyzsh plugins/isodate -zgenom ohmyzsh plugins/rsync -zgenom ohmyzsh plugins/systemadmin -if command -v fzf > /dev/null 2>&1; then - export DISABLE_FZF_KEY_BINDINGS=true - zgenom ohmyzsh plugins/fzf - # fzf - [ -e /usr/share/doc/fzf/examples/key-bindings.zsh ] && source /usr/share/doc/fzf/examples/key-bindings.zsh - [ -e /usr/share/doc/fzf/examples/completion.zsh ] && source /usr/share/doc/fzf/examples/completion.zsh -fi -if command -v git > /dev/null 2>&1; then - GIT_AUTO_FETCH_INTERVAL=3600 - zgenom ohmyzsh plugins/git - zgenom ohmyzsh plugins/git-auto-fetch - zgenom ohmyzsh plugins/git-extras - zgenom ohmyzsh plugins/github - zgenom load paulirish/git-open -fi -if command -v psql > /dev/null 2>&1; then - zgenom ohmyzsh plugins/postgres -fi -if command -v sudo > /dev/null 2>&1; then - zgenom ohmyzsh plugins/sudo -fi -if command -v systemctl > /dev/null 2>&1; then - zgenom ohmyzsh plugins/systemd -fi -if command -v vim > /dev/null 2>&1; then - zgenom ohmyzsh plugins/vim-interaction -fi -zgenom ohmyzsh plugins/web-search - -zgenom ohmyzsh plugins/tmux -zstyle ':prezto:module:tmux:auto-start' local 'no' -zstyle ':prezto:module:tmux:auto-start' remote 'yes' -zstyle ':prezto:module:tmux:session' name "$(hostname)" -zgenom load laggardkernel/zsh-tmux - diff --git a/65-prompt.zsh b/45-prompt.zsh similarity index 73% rename from 65-prompt.zsh rename to 45-prompt.zsh index 2b46db3..2de2418 100644 --- a/65-prompt.zsh +++ b/45-prompt.zsh @@ -29,7 +29,12 @@ fi autoload is-at-least if is-at-least "5.2" "$ZSH_VERSION"; then - zgenom load "denysdovhan/spaceship-prompt" + ZSH_THEME="spaceship" + if [ ! -d "$ZSH_CUSTOM/themes/${ZSH_THEME}" ]; then + git clone https://github.com/spaceship-prompt/spaceship-prompt "$ZSH_CUSTOM/themes/${ZSH_THEME}" + ln -s "${ZSH_CUSTOM}/themes/${ZSH_THEME}/${ZSH_THEME}.zsh-theme" "${ZSH_CUSTOM}/themes/${ZSH_THEME}.zsh-theme" + fi else - zgenom load "nojhan/liquidprompt" + ZSH_THEME="eastwood" fi + diff --git a/55-agents.zsh b/55-agents.zsh index 8e5111c..11f7f84 100644 --- a/55-agents.zsh +++ b/55-agents.zsh @@ -1,4 +1,4 @@ -# Copy this file to agents.user.zsh and modify to your needs +# Copy this file to 55-agents.user.zsh and modify to your needs ## # SSH agent @@ -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 -# zgenom ohmyzsh plugins/ssh-agent +# plugins+=(ssh-agent) ## # GPG agent ## -# zgenom ohmyzsh plugins/gpg-agent +# plugins+=(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 -# zgenom ohmyzsh plugins/keychain +# plugins+=(keychain) diff --git a/78-scripts.zsh b/65-scripts.zsh similarity index 100% rename from 78-scripts.zsh rename to 65-scripts.zsh diff --git a/82-plugins.zsh b/82-plugins.zsh new file mode 100644 index 0000000..536070d --- /dev/null +++ b/82-plugins.zsh @@ -0,0 +1,63 @@ +[ -e "$ZDOTDIR/12-functions.zsh" ] && source "$ZDOTDIR/12-functions.zsh" + +if [ ! -e "$ZSH/oh-my-zsh.sh" ]; then + git clone "https://github.com/ohmyzsh/ohmyzsh" "$ZSH" +fi + +if [ ! -d "$ZSH_CUSTOM" ]; then + mkdir -p "$ZSH_CUSTOM" +fi + +add_custom_plugin "https://github.com/tautomer/update-ohmyzsh-custom-plugins.git" update-custom-plugins +add_custom_plugin "https://github.com/willghatch/zsh-saneopt" saneopt +add_custom_plugin "https://github.com/mafredri/zsh-async" async +add_custom_plugin "https://github.com/djui/alias-tips" alias-tips +add_custom_plugin "https://github.com/rupa/z" z + +if [[ "$DISPLAY" != '' ]] && command -v xdotool > /dev/null 2>&1 && command -v wmctrl > /dev/null 2>&1; then + add_custom_plugin "https://github.com/marzocchi/zsh-notify" 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 + add_custom_plugin "https://github.com/jimeh/zsh-peco-history" zsh-peco-history +fi + +plugins+=(autojump command-not-found common-aliases debian isodate nmap rsync systemadmin web-search) + +if command -v fzf > /dev/null 2>&1; then + export DISABLE_FZF_KEY_BINDINGS=true + plugins+=(fzf) + # fzf + [ -e /usr/share/doc/fzf/examples/key-bindings.zsh ] && source /usr/share/doc/fzf/examples/key-bindings.zsh + [ -e /usr/share/doc/fzf/examples/completion.zsh ] && source /usr/share/doc/fzf/examples/completion.zsh +fi +if command -v git > /dev/null 2>&1; then + GIT_AUTO_FETCH_INTERVAL=3600 + plugins+=(git git-auto-fetch git-extras github) + add_custom_plugin "https://github.com/paulirish/git-open" git-open +fi +if command -v psql > /dev/null 2>&1; then + plugins+=(postgres) +fi +if command -v sudo > /dev/null 2>&1; then + plugins+=(sudo) +fi +if command -v systemctl > /dev/null 2>&1; then + plugins+=(systemd) +fi +if command -v vim > /dev/null 2>&1; then + plugins+=(vim-interaction) +fi +if command -v tmux > /dev/null 2>&1; then + plugins+=(tmux) + zstyle ':prezto:module:tmux:auto-start' local 'no' + zstyle ':prezto:module:tmux:auto-start' remote 'yes' + zstyle ':prezto:module:tmux:session' name "$(hostname)" + add_custom_plugin "https://github.com/laggardkernel/zsh-tmux" zsh-tmux +fi +if command -v kitty > /dev/null 2>&1; then + add_custom_plugin "https://github.com/redxtech/zsh-kitty" zsh-kitty +fi + diff --git a/85-compinit.zsh b/85-compinit.zsh index d3d2d07..3fcd743 100644 --- a/85-compinit.zsh +++ b/85-compinit.zsh @@ -1,17 +1,6 @@ -if [ -z "${ZSH_IS_SUBSHELL}" ]; then - typeset -i _compinit_updated_at=$(date +'%j' -r $ZSH_COMPDUMP 2>/dev/null || stat -f '%Sm' -t '%j' $ZSH_COMPDUMP 2>/dev/null) - ZGEN_COMPINIT_FLAGS="-i" - if [ $(date +'%j') = $_compinit_updated_at ]; then - ZGEN_COMPINIT_FLAGS+=" -C" - fi - unset _compinit_updated_at +[ -e "$ZDOTDIR/12-functions.zsh" ] && source "$ZDOTDIR/12-functions.zsh" - zmodload -i zsh/complist - autoload -Uz compinit && eval "compinit $ZGEN_COMPINIT_FLAGS -d $ZSH_COMPDUMP" - - #zgenom load marlonrichert/zsh-autocomplete - zgenom load zsh-users/zsh-autosuggestions -fi +add_custom_plugin "https://github.com/zsh-users/zsh-autosuggestions" zsh-autosuggestions # Speed up autocomplete, force prefix mapping zstyle ':completion:*' accept-exact '*(N)' @@ -39,6 +28,6 @@ zstyle ':completion:*:(ssh|scp|rsync):*:hosts-domain' ignored-patterns '<->.<->. zstyle ':completion:*:(ssh|scp|rsync):*:hosts-ipaddr' ignored-patterns '^<->.<->.<->.<->' '127.0.0.<->' # Вызов в этом месте и в таком порядке -zgenom load zsh-users/zsh-syntax-highlighting -zgenom load zsh-users/zsh-history-substring-search +add_custom_plugin "https://github.com/zsh-users/zsh-syntax-highlighting" zsh-syntax-highlighting +add_custom_plugin "https://github.com/zsh-users/zsh-history-substring-search" zsh-history-substring-search diff --git a/88-ohmyzsh.zsh b/88-ohmyzsh.zsh new file mode 100644 index 0000000..284b5e6 --- /dev/null +++ b/88-ohmyzsh.zsh @@ -0,0 +1,12 @@ +zstyle ':omz:update' mode disabled + +# following commands will be prevented to have filename correction: +# cp, ebuild, gist, heroku, hpodder, man, mkdir, mv, mysql, sudo +ENABLE_CORRECTION=true + +HYPHEN_INSENSITIVE=true + +COMPLETION_WAITING_DOTS=true + +source $ZSH/oh-my-zsh.sh + diff --git a/95-finish.zsh b/95-finish.zsh index 6e9d3b6..e69de29 100644 --- a/95-finish.zsh +++ b/95-finish.zsh @@ -1,3 +0,0 @@ -#zgenom save 2>/dev/null -#zgenom compile $ZDOTDIR - diff --git a/README.md b/README.md index d97cba2..3af7e8b 100644 --- a/README.md +++ b/README.md @@ -113,19 +113,19 @@ Host * ## Инициализация После редактирования файлов настройки запустить `zsh`, в результате чего будет -загружен менеджер пакетов [`zgenom`](https://github.com/jandamm/zgenom/) и необходимые плагины. +загружен фреймворк [Oh My Zsh](https://github.com/ohmyzsh/ohmyzsh) и сторонние плагины. ## Обновление -Обновление менеджера пакетов: +Обновление фреймворка: ```sh -zgenom selfupdate +omz update ```` Обновление плагинов: ```sh -zgenom update +update-custom-plugins ```