Переход на использование Oh My Zsh

This commit is contained in:
Andrei Astafev 2021-12-06 00:42:07 +03:00
parent 97d234df5f
commit 8d03a2ed06
12 changed files with 121 additions and 110 deletions

7
.zshrc
View File

@ -3,12 +3,13 @@ for S in \
15-env \ 15-env \
25-history \ 25-history \
35-options \ 35-options \
45-plugins \ 45-prompt \
55-agents \ 55-agents \
65-prompt \ 65-scripts \
75-aliases \ 75-aliases \
78-scripts \ 82-plugins \
85-compinit \ 85-compinit \
88-ohmyzsh \
95-finish 95-finish
do do
N="${S//[0-9\-]/}" N="${S//[0-9\-]/}"

8
12-functions.zsh Normal file
View File

@ -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)
}

View File

@ -3,22 +3,17 @@ export XDG_CACHE_HOME="$HOME/.cache"
export XDG_DATA_HOME="$HOME/.local/share" export XDG_DATA_HOME="$HOME/.local/share"
export ZSH_CACHE_DIR="$XDG_CACHE_HOME/zsh" export ZSH_CACHE_DIR="$XDG_CACHE_HOME/zsh"
export ZSH_COMPDUMP="$ZSH_CACHE_DIR/completions/dump" export ZSH="$ZSH_CACHE_DIR/ohmyzsh"
export ZGEN_SOURCE="$ZSH_CACHE_DIR" export ZSH_CUSTOM="$ZSH_CACHE_DIR/custom"
export ZGEN_SOURCE_BIN="$ZSH_CACHE_DIR/plugins" export ZSH_COMPDUMP="${ZSH_CACHE_DIR}/zcompdump-${HOST/.*/}-${ZSH_VERSION}"
export ZGEN_DIR="$ZSH_CACHE_DIR/zgenom" plugins=()
if ps $PPID | grep mc; then if ps $PPID | grep mc; then
export ZSH_IS_SUBSHELL=1 export ZSH_IS_SUBSHELL=1
fi fi
ZPFX=$ZGEN_DIR/polaris
DISABLE_AUTO_UPDATE=true
# PATH # PATH
for P in \ for P in \
"$HOME/.vim/plugged/vim-superman/bin" \
"$HOME/bin" \ "$HOME/bin" \
"$HOME/.local/bin" "$HOME/.local/bin"
do do
@ -33,6 +28,17 @@ typeset -U PATH
export GNUPGHOME="$XDG_CONFIG_HOME/gnupg" export GNUPGHOME="$XDG_CONFIG_HOME/gnupg"
export SVDIR="$HOME/sv" 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
UNCRUSTIFY_CONFIG="${XDG_CONFIG_HOME}/uncrustify/default.cfg" UNCRUSTIFY_CONFIG="${XDG_CONFIG_HOME}/uncrustify/default.cfg"
[ -e "${UNCRUSTIFY_CONFIG}" ] && export UNCRUSTIFY_CONFIG [ -e "${UNCRUSTIFY_CONFIG}" ] && export UNCRUSTIFY_CONFIG

View File

@ -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

View File

@ -29,7 +29,12 @@ fi
autoload is-at-least autoload is-at-least
if is-at-least "5.2" "$ZSH_VERSION"; then 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 else
zgenom load "nojhan/liquidprompt" ZSH_THEME="eastwood"
fi fi

View File

@ -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 # SSH agent
@ -6,12 +6,12 @@
# 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
# zgenom ohmyzsh plugins/ssh-agent # plugins+=(ssh-agent)
## ##
# GPG agent # GPG agent
## ##
# zgenom ohmyzsh plugins/gpg-agent # plugins+=(gpg-agent)
## ##
# Keychain # Keychain
@ -19,5 +19,5 @@
# 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
# zgenom ohmyzsh plugins/keychain # plugins+=(keychain)

63
82-plugins.zsh Normal file
View File

@ -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

View File

@ -1,17 +1,6 @@
if [ -z "${ZSH_IS_SUBSHELL}" ]; then [ -e "$ZDOTDIR/12-functions.zsh" ] && source "$ZDOTDIR/12-functions.zsh"
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
zmodload -i zsh/complist add_custom_plugin "https://github.com/zsh-users/zsh-autosuggestions" zsh-autosuggestions
autoload -Uz compinit && eval "compinit $ZGEN_COMPINIT_FLAGS -d $ZSH_COMPDUMP"
#zgenom load marlonrichert/zsh-autocomplete
zgenom load zsh-users/zsh-autosuggestions
fi
# Speed up autocomplete, force prefix mapping # Speed up autocomplete, force prefix mapping
zstyle ':completion:*' accept-exact '*(N)' 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.<->' zstyle ':completion:*:(ssh|scp|rsync):*:hosts-ipaddr' ignored-patterns '^<->.<->.<->.<->' '127.0.0.<->'
# Вызов в этом месте и в таком порядке # Вызов в этом месте и в таком порядке
zgenom load zsh-users/zsh-syntax-highlighting add_custom_plugin "https://github.com/zsh-users/zsh-syntax-highlighting" zsh-syntax-highlighting
zgenom load zsh-users/zsh-history-substring-search add_custom_plugin "https://github.com/zsh-users/zsh-history-substring-search" zsh-history-substring-search

12
88-ohmyzsh.zsh Normal file
View File

@ -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

View File

@ -1,3 +0,0 @@
#zgenom save 2>/dev/null
#zgenom compile $ZDOTDIR

View File

@ -113,19 +113,19 @@ Host *
## Инициализация ## Инициализация
После редактирования файлов настройки запустить `zsh`, в результате чего будет После редактирования файлов настройки запустить `zsh`, в результате чего будет
загружен менеджер пакетов [`zgenom`](https://github.com/jandamm/zgenom/) и необходимые плагины. загружен фреймворк [Oh My Zsh](https://github.com/ohmyzsh/ohmyzsh) и сторонние плагины.
## Обновление ## Обновление
Обновление менеджера пакетов: Обновление фреймворка:
```sh ```sh
zgenom selfupdate omz update
```` ````
Обновление плагинов: Обновление плагинов:
```sh ```sh
zgenom update update-custom-plugins
``` ```