From e09e731101a3b49c94f211030c11c1ddc2bc3b59 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Sun, 18 Dec 2022 18:58:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BC=D0=B5=D1=87=D0=B0=D0=BD=D0=B8=D0=B9=20shellcheck?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .zshenv | 31 +++++++++++++++++++------------ .zshrc | 13 ++++++++----- 05-start.zsh | 3 +++ 15-options.zsh | 5 ++++- 25-history.zsh | 3 +++ 42-zinit.zsh | 11 +++++++---- 45-plugins.zsh | 5 ++++- 55-agents.zsh | 9 ++++++--- 65-scripts.zsh | 5 ++++- 75-aliases.zsh | 5 ++++- 82-completion.zsh | 9 ++++++--- 85-keybindings.zsh | 3 +++ 88-prompt.zsh | 5 ++++- 95-finish.zsh | 3 +++ 14 files changed, 78 insertions(+), 32 deletions(-) diff --git a/.zshenv b/.zshenv index bdaca90..7de2135 100644 --- a/.zshenv +++ b/.zshenv @@ -1,9 +1,12 @@ +# shellcheck shell=bash +# vim: ft=sh + # Запрет чтения настроек из системного каталога /etc unsetopt GLOBAL_RCS # PATH {{{ # Ruby -if which ruby >/dev/null && which gem >/dev/null; then +if command -v ruby >/dev/null && command -v gem >/dev/null; then path=("$(ruby -r rubygems -e 'puts Gem.user_dir')/bin" $path) fi @@ -31,34 +34,38 @@ export ZSH_COMPDUMP="$ZSH_CACHE_DIR/zcompdump-${HOST/.*/}-$ZSH_VERSION" # 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 +# askpass # {{{ +if [[ -n ${DISPLAY+set} ]]; then + if command -v /usr/lib/openssh/gnome-ssh-askpass >/dev/null 2>&1; then + # Gnome export SSH_ASKPASS=/usr/lib/openssh/gnome-ssh-askpass - elif command -v /usr/bin/lxqt-openssh-askpass 2>&1 >/dev/null; then + elif command -v /usr/bin/lxqt-openssh-askpass >/dev/null 2>&1; then + # LxQt export SSH_ASKPASS=/usr/bin/lxqt-openssh-askpass - elif command -v /usr/bin/ssh-askpass 2>&1 >/dev/null; then + elif command -v /usr/bin/ssh-askpass >/dev/null 2>&1; then + # X11 export SSH_ASKPASS=/usr/bin/ssh-askpass fi fi # }}} -# Настройка uncrustify +# 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 +# Intel OneAPI #{{{ +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 ) + /opt/intel/oneapi/vtune/latest/vtune-vars.sh ) - for f in ${INTEL_VARS[*]}; do - [ -r "$f" ] && source "$f" > /dev/null + for f in "${INTEL_VARS[@]}"; do + if [ -r "$f" ]; then source "$f" >/dev/null; fi done fi +# }}} [ -r "$ZDOTDIR/.zshenv.user" ] && source "$ZDOTDIR/.zshenv.user" diff --git a/.zshrc b/.zshrc index bf957f0..ed5964e 100644 --- a/.zshrc +++ b/.zshrc @@ -1,3 +1,6 @@ +# shellcheck shell=bash +# vim: ft=sh + # Profiling start # zmodload zsh/zprof @@ -16,11 +19,11 @@ for S in \ 95-finish do N="${S//[0-9\-]/}" - [ -r "$ZDOTDIR/$S.pre.zsh" ] && source "$ZDOTDIR/$S.pre.zsh" || true - [ -r "$ZDOTDIR/$S.zsh" ] && source "$ZDOTDIR/$S.zsh" || true - [ -r "$ZDOTDIR/$S.user.zsh" ] && source "$ZDOTDIR/$S.user.zsh" || true - [ -r "$ZDOTDIR/$N.user.zsh" ] && source "$ZDOTDIR/$N.user.zsh" || true - [ -r "$ZDOTDIR/$S.post.zsh" ] && source "$ZDOTDIR/$S.post.zsh" || true + if [[ -r "$ZDOTDIR/$S.pre.zsh" ]]; then source "$ZDOTDIR/$S.pre.zsh"; fi + if [[ -r "$ZDOTDIR/$S.zsh" ]]; then source "$ZDOTDIR/$S.zsh"; fi + if [[ -r "$ZDOTDIR/$S.user.zsh" ]]; then source "$ZDOTDIR/$S.user.zsh"; fi + if [[ -r "$ZDOTDIR/$N.user.zsh" ]]; then source "$ZDOTDIR/$N.user.zsh"; fi + if [[ -r "$ZDOTDIR/$S.post.zsh" ]]; then source "$ZDOTDIR/$S.post.zsh"; fi done # zprof diff --git a/05-start.zsh b/05-start.zsh index 5dc8fc6..a972243 100644 --- a/05-start.zsh +++ b/05-start.zsh @@ -1,3 +1,6 @@ +# shellcheck shell=bash +# vim: ft=sh + # Enable Powerlevel10k instant prompt. # Should stay close to the top of ~/.config/zsh/.zshrc. # Initialization code that may require console input diff --git a/15-options.zsh b/15-options.zsh index 8f07b1c..5afa31b 100644 --- a/15-options.zsh +++ b/15-options.zsh @@ -1,3 +1,6 @@ +# shellcheck shell=bash +# vim: ft=sh + 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. @@ -23,5 +26,5 @@ if [ -z ${DISABLE_MAGIC_FUNCTIONS+set} ]; then fi # Подсветка вывода основных команд -[[ -r /etc/grc.zsh ]] && source /etc/grc.zsh +if [[ -r /etc/grc.zsh ]]; then source /etc/grc.zsh; fi diff --git a/25-history.zsh b/25-history.zsh index 12f5290..55f15b5 100644 --- a/25-history.zsh +++ b/25-history.zsh @@ -1,3 +1,6 @@ +# shellcheck shell=bash +# vim: ft=sh + HISTFILE="$ZSH_CACHE_DIR/history" HISTSIZE=100000 SAVEHIST=500000 diff --git a/42-zinit.zsh b/42-zinit.zsh index 8118756..12ea42e 100644 --- a/42-zinit.zsh +++ b/42-zinit.zsh @@ -1,3 +1,6 @@ +# shellcheck shell=bash +# vim: ft=sh + declare -A ZINIT ZINIT[HOME_DIR]="$ZSH_CACHE_DIR/zinit" ZINIT[PLUGINS_DIR]="$ZSH_CACHE_DIR/plugins" @@ -5,12 +8,12 @@ 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 --depth 1 https://github.com/zdharma-continuum/zinit "$ZINIT[HOME_DIR]" - zcompile "$ZINIT[HOME_DIR]/zinit.zsh" +if [ ! -d "${ZINIT}[HOME_DIR]" ]; then + git clone --depth 1 https://github.com/zdharma-continuum/zinit "${ZINIT}[HOME_DIR]" + zcompile "${ZINIT}[HOME_DIR]/zinit.zsh" fi -source "$ZINIT[HOME_DIR]/zinit.zsh" +source "${ZINIT}[HOME_DIR]/zinit.zsh" autoload -Uz _zinit (( ${+_comps} )) && _comps[zinit]=_zinit diff --git a/45-plugins.zsh b/45-plugins.zsh index 78e3f1c..fb4c849 100644 --- a/45-plugins.zsh +++ b/45-plugins.zsh @@ -1,3 +1,6 @@ +# shellcheck shell=bash +# vim: ft=sh + zinit load willghatch/zsh-saneopt zinit load mafredri/zsh-async @@ -6,7 +9,7 @@ export ZSHZ_DATA="${ZSH_CACHE_DIR}/z" zinit ice wait'!0' depth'1' zinit light agkozak/zsh-z -if [ "$(id -u)" != "0" ] && [ -n ${DISPLAY+set} ]; then +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 diff --git a/55-agents.zsh b/55-agents.zsh index 467d9a2..da495f0 100644 --- a/55-agents.zsh +++ b/55-agents.zsh @@ -1,3 +1,6 @@ +# shellcheck shell=bash +# vim: ft=sh + # Copy this file to 55-agents.user.zsh and modify to your needs ## @@ -13,9 +16,9 @@ ## if command -v gpg-agent >/dev/null 2>&1; then zinit snippet OMZP::gpg-agent -fi -if command -v gpg-conf >/dev/null 2>&1; then - gpgconf --create-socketdir + if command -v gpg-conf >/dev/null 2>&1; then + gpgconf --create-socketdir + fi fi ## diff --git a/65-scripts.zsh b/65-scripts.zsh index d6c317f..dd45795 100644 --- a/65-scripts.zsh +++ b/65-scripts.zsh @@ -1,3 +1,6 @@ +# shellcheck shell=bash +# vim: ft=sh + # Обновление конфигурации zsh, менеджера zinit и плагинов zu() { git -C "${ZDOTDIR}" pull && zinit update --parallel @@ -68,7 +71,7 @@ psgrep() { # Kills any process that matches a regexp passed to it killit() { - ps aux | grep -v "grep" | grep "$@" | awk '{print $2}' | xargs sudo kill + ps aux | grep -v grep | grep "$@" | awk '{print $2}' | xargs sudo kill } # gather external ip address diff --git a/75-aliases.zsh b/75-aliases.zsh index d671b34..272ae7f 100644 --- a/75-aliases.zsh +++ b/75-aliases.zsh @@ -1,3 +1,6 @@ +# shellcheck shell=bash +# vim: ft=sh + # Dotdrop alias dotdrop="$HOME/etc/dotdrop.sh" --cfg="$HOME/etc/config.yaml" @@ -37,7 +40,7 @@ fi command -v feh > /dev/null 2>&1 && alias feh="feh --cache-size 256 --version-sort --sort filename --image-bg black" # Замена шрифта у заголовка окна в i3 при использовании ssh или mosh -if [ -n ${DISPLAY+set} ] ; then +if [ ! -z ${DISPLAY+set} ] ; then if command -v i3-msg >/dev/null 2>&1 ; then i3-mosh () { i3-msg -q title_format "%title" diff --git a/82-completion.zsh b/82-completion.zsh index 4f1a21f..2fecc2e 100644 --- a/82-completion.zsh +++ b/82-completion.zsh @@ -1,7 +1,10 @@ +# shellcheck shell=bash +# vim: ft=sh + # Speed up autocomplete, force prefix mapping zstyle ':completion:*' accept-exact '*(N)' zstyle ':completion:*' use-cache on -zstyle ':completion:*' cache-path $ZSH_CACHE_DIR +zstyle ':completion:*' cache-path "$ZSH_CACHE_DIR" zstyle ':completion:*:processes' command 'ps -ax' zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;32' @@ -33,10 +36,10 @@ zinit wait'!0' lucid light-mode depth'1' for \ atload"!_zsh_autosuggest_start" \ zsh-users/zsh-autosuggestions -if [ -n ${ZSH_MC_SUBSHELL+set} ] && [ -n ${SSH_CONNECTION+set} ]; then +if [[ -n ${ZSH_MC_SUBSHELL+set} ]] && [[ -n ${SSH_CONNECTION+set} ]]; then zinit load zsh-users/zsh-history-substring-search else - zstyle ":history-search-multi-word" page-size "$(($LINES/2))" + zstyle ":history-search-multi-word" page-size "$((LINES/2))" zstyle ":plugin:history-search-multi-word" clear-on-cancel "yes" zinit wait'!0' lucid light-mode depth'1' for \ zdharma-continuum/history-search-multi-word \ diff --git a/85-keybindings.zsh b/85-keybindings.zsh index 610c3e5..c17d7a8 100644 --- a/85-keybindings.zsh +++ b/85-keybindings.zsh @@ -1,3 +1,6 @@ +# shellcheck shell=bash +# vim: ft=sh + # Defined shortcut keys: [Esc] [Esc] bindkey '\e\e' send-break diff --git a/88-prompt.zsh b/88-prompt.zsh index 3371ef9..05cab4e 100644 --- a/88-prompt.zsh +++ b/88-prompt.zsh @@ -1,9 +1,12 @@ +# shellcheck shell=bash +# vim: ft=sh + 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 + [[ -r "$ZDOTDIR/.p10k.zsh" ]] && source "$ZDOTDIR/.p10k.zsh" else zinit load agkozak/agkozak-zsh-prompt fi diff --git a/95-finish.zsh b/95-finish.zsh index e69de29..407975d 100644 --- a/95-finish.zsh +++ b/95-finish.zsh @@ -0,0 +1,3 @@ +# shellcheck shell=bash +# vim: ft=sh +