From 47b217005839a81f600843d0539608676f69cbbe Mon Sep 17 00:00:00 2001 From: Konstantin Demin Date: Fri, 23 Feb 2024 21:46:04 +0300 Subject: [PATCH] zsh: update --- .cache/zsh/compzwc/.keep | 0 .config/dotfiles/gitignore | 2 ++ .config/dotfiles/woodpecker.yml | 4 ++++ .config/zsh/_.zsh | 11 +++------ .config/zsh/alias/containers.zsh | 16 ++++++++----- .config/zsh/env.zsh | 6 ++--- .config/zsh/lib/completion.zsh | 36 ++++++++++++++++++------------ .config/zsh/lib/git.zsh | 5 +---- .config/zsh/lib/history.zsh | 2 +- .config/zsh/lib/selfservice.zsh | 22 ++++++++++-------- .config/zsh/local/completion/.keep | 0 .config/zsh/rc.zsh | 11 +++++---- .config/zsh/rc/completion.zsh | 8 +++---- .config/zsh/rc/keyboard.zsh | 2 +- 14 files changed, 72 insertions(+), 53 deletions(-) create mode 100644 .cache/zsh/compzwc/.keep create mode 100644 .config/zsh/local/completion/.keep diff --git a/.cache/zsh/compzwc/.keep b/.cache/zsh/compzwc/.keep new file mode 100644 index 0000000..e69de29 diff --git a/.config/dotfiles/gitignore b/.config/dotfiles/gitignore index 8d1df39..339034d 100644 --- a/.config/dotfiles/gitignore +++ b/.config/dotfiles/gitignore @@ -1,6 +1,7 @@ * !/.cache/zsh/compcache/.keep !/.cache/zsh/completion/.keep +!/.cache/zsh/compzwc/.keep !/.config/dotfiles/bin/.keep !/.config/dotfiles/gen-gitignore.sh !/.config/dotfiles/gitignore @@ -56,6 +57,7 @@ !/.config/zsh/lib/title.zsh !/.config/zsh/local.zsh.example !/.config/zsh/local/.keep +!/.config/zsh/local/completion/.keep !/.config/zsh/opt.zsh !/.config/zsh/opt/chase.zsh !/.config/zsh/opt/completion.zsh diff --git a/.config/dotfiles/woodpecker.yml b/.config/dotfiles/woodpecker.yml index 4b406a9..11931fe 100644 --- a/.config/dotfiles/woodpecker.yml +++ b/.config/dotfiles/woodpecker.yml @@ -32,3 +32,7 @@ steps: : # try shellcheck (except for *.zsh) git ls-files | grep -Fv '.zsh' | sort -uV | xargs -r file -N -i | grep text/x-shellscript | cut -d: -f1 \ | xargs -r -n1 shellcheck + +## personal tweaks :) +labels: + network: dmz diff --git a/.config/zsh/_.zsh b/.config/zsh/_.zsh index f0711e2..83465fa 100644 --- a/.config/zsh/_.zsh +++ b/.config/zsh/_.zsh @@ -15,11 +15,6 @@ ZSHU[d_var]="${ZSHU[d_conf]}/var" ZSHU[d_bin]="${ZDOTDIR}/.config/dotfiles/bin" ZSHU[d_scripts]="${ZDOTDIR}/.config/dotfiles/scripts" -for i ( d_zdot d_cache d_conf d_bin d_scripts d_var ) ; do - d=${ZSHU[$i]} - [ -d "$d" ] || mkdir -p "$d" -done ; unset i d - ## early escape unsetopt global_rcs @@ -45,10 +40,10 @@ done ; unset n f for n ( ${zshu_parts} ) ; do d="${ZSHU[d_conf]}/$n" [ -d "$d" ] || continue - for i ( $d/*.zsh(N.r) ) ; do + for i ( "$d"/*.zsh(N.r) ) ; do source "$i" - done ; unset i -done ; unset n d + done +done ; unset i n d unset zshu_parts diff --git a/.config/zsh/alias/containers.zsh b/.config/zsh/alias/containers.zsh index 12a31d6..c45f94d 100644 --- a/.config/zsh/alias/containers.zsh +++ b/.config/zsh/alias/containers.zsh @@ -2,23 +2,29 @@ alias bud='buildah bud --isolation chroot --network host --format docker -f ' -alias pod-run='podman run -e "TERM=${TERM:-linux}" --network host --rm -it ' -alias pod-run-sh="pod-run --entrypoint='[\"/bin/sh\"]' --user=0:0 " +alias pod-run='podman run -e "TERM=${TERM:-linux}" --rm -it ' +alias pod-run-sh="pod-run --network host --entrypoint='[\"/bin/sh\"]' --user=0:0 " alias pod-ps='podman ps ' alias pod-images='podman images --format "table {{.ID}} {{.Repository}}:{{.Tag}} {{.Size}} {{.Created}} |{{.CreatedAt}}" ' alias pod-inspect='podman inspect ' alias pod-logs='podman logs ' sko-inspect() { - command skopeo inspect "docker://${1:?}" + local i + i="${1:?}" ; shift + command skopeo inspect "docker://$i" "$@" } sko-list-tags() { - command skopeo list-tags "docker://${1:?}" + local i + i="${1:?}" ; shift + command skopeo list-tags "docker://$i" "$@" } pod-dive() { - command dive "podman://${1:?}" + local i + i="${1:?}" ; shift + command dive "podman://$i" "$@" } jq-visual() { diff --git a/.config/zsh/env.zsh b/.config/zsh/env.zsh index 076b25b..b83ad29 100644 --- a/.config/zsh/env.zsh +++ b/.config/zsh/env.zsh @@ -5,7 +5,7 @@ function { local -a p local -aU t npath games - p=( $path ) + p=( ${path} ) ## strip "games" first :) t=( ${(@)p:#*games*} ) @@ -36,9 +36,9 @@ function { ## finally... games! xD npath+=( /usr/local/games /usr/games ) - npath+=( $games ) + npath+=( ${games} ) - path=( $npath ) + path=( ${npath} ) hash -f } diff --git a/.config/zsh/lib/completion.zsh b/.config/zsh/lib/completion.zsh index af25e2f..91299bf 100644 --- a/.config/zsh/lib/completion.zsh +++ b/.config/zsh/lib/completion.zsh @@ -3,10 +3,12 @@ typeset -gA ZSHU_COMP_FORCE ZSHU[f_compdump]="${ZSHU[d_cache]}/compdump" +ZSHU[d_completion]="${ZSHU[d_cache]}/completion" +ZSHU[d_compzwc]="${ZSHU[d_cache]}/compzwc" ZSHU[d_compcache]="${ZSHU[d_cache]}/compcache" -[ -d "${ZSHU[d_compcache]}" ] || mkdir -p "${ZSHU[d_compcache]}" -fpath=( "${ZSHU[d_cache]}/completion" $fpath ) +typeset -a ZSHU_SYS_FPATH=( ${fpath} ) +fpath=( "${ZSHU[d_compzwc]}" "${ZSHU[d_completion]}" ${fpath} ) __z_compdump_print() { printf '#zshu %s %s\n' "$1" "${(P)1}" ; } @@ -73,17 +75,19 @@ __z_comp_external() { (( ${+commands[$c]} )) || return 2 if ! (( ${+ZSHU_COMP_FORCE[$c]} )) ; then - (( ${+_comps[$c]} )) && return + (( ${+_comps[$c]} )) && return 0 fi - f="${ZSHU[d_cache]}/completion/_$c" + f="${ZSHU[d_completion]}/_$c" if ! [ -s "$f" ] ; then if ! "$@" > "$f" ; then rm -f "$f" return 3 fi fi - zcompile -zUR "$f" || return 4 + # zcompile -zR "$f" + # mv -f "$f.zwc" "${ZSHU[d_compzwc]}/$c.zwc" + # emulate zsh -c "autoload -Uz _$c" autoload -Uz "_$c" return 0 @@ -95,30 +99,34 @@ __z_comp_system() { (( ${+commands[$1]} )) || return 1 (( ${+_comps[$1]} )) && return 2 - for d ( $fpath ) ; do + (( ${+ZSHU_COMP_FORCE[$c]} )) && return 0 + + local -a _fpath + _fpath=( ${fpath} ) + fpath=( ${ZSHU_SYS_FPATH} ) + + for d ( ${fpath} ) ; do [ -s "$d/_$1" ] || continue + # emulate zsh -c "autoload -Uz _$1" autoload -Uz "_$1" + fpath=( ${_fpath} ) return 0 done - + fpath=( ${_fpath} ) return 3 } ## reload or new session are required to regenerate compcache z-comp-invalidate() { - local f - [ -n "$1" ] || return 1 - f="${ZSHU[d_cache]}/completion/_$1" - rm -f "$f.zwc" - [ -f "$f" ] || return 2 - rm -f "$f" + # rm -f "${ZSHU[d_completion]}/_$1" "${ZSHU[d_compzwc]}/_$1.zwc" "${ZSHU[d_compzwc]}/$1.zwc" + rm -f "${ZSHU[d_completion]}/_$1" } ## reload or new session are required to regenerate completions z-comp-flush() { - find "${ZSHU[d_cache]}/completion/" -xdev -type f '!' -name '.keep' -delete + find "${ZSHU[d_completion]}/" "${ZSHU[d_compzwc]}/" -xdev -type f '!' -name '.keep' -delete } z-comp-auto() { diff --git a/.config/zsh/lib/git.zsh b/.config/zsh/lib/git.zsh index 6518a79..68ad5c6 100644 --- a/.config/zsh/lib/git.zsh +++ b/.config/zsh/lib/git.zsh @@ -31,10 +31,7 @@ z-git-test() { __z_git_pwd() { local x - unset 'ZSHU_PS[git_ref]' 'ZSHU_PS[git_changes]' 'ZSHU_PS[git_tag]' - unset 'ZSHU_GIT[path_root]' 'ZSHU_GIT[path_mid]' 'ZSHU_GIT[path_last]' - unset 'ZSHU_GIT[commit]' 'ZSHU_GIT[detached]' 'ZSHU_GIT[ref]' 'ZSHU_GIT[remote]' 'ZSHU_GIT[tag]' - unset 'ZSHU_GIT[ref_behind]' 'ZSHU_GIT[ref_ahead]' 'ZSHU_GIT[ref_changes]' + unset 'ZSHU_PS[git_ref]' 'ZSHU_PS[git_changes]' 'ZSHU_PS[git_tag]' 'ZSHU_GIT[path_root]' 'ZSHU_GIT[path_mid]' 'ZSHU_GIT[path_last]' 'ZSHU_GIT[commit]' 'ZSHU_GIT[detached]' 'ZSHU_GIT[ref]' 'ZSHU_GIT[remote]' 'ZSHU_GIT[tag]' 'ZSHU_GIT[ref_behind]' 'ZSHU_GIT[ref_ahead]' 'ZSHU_GIT[ref_changes]' z-git-test || return diff --git a/.config/zsh/lib/history.zsh b/.config/zsh/lib/history.zsh index fcfb437..dfd35e6 100644 --- a/.config/zsh/lib/history.zsh +++ b/.config/zsh/lib/history.zsh @@ -4,7 +4,7 @@ z-history() { local list zparseopts -E l=list - if [[ -n "$list" ]]; then + if [ -n "${list}" ]; then builtin fc "$@" else [[ ${@[-1]-} = *[0-9]* ]] && builtin fc -il "$@" || builtin fc -il "$@" 1 diff --git a/.config/zsh/lib/selfservice.zsh b/.config/zsh/lib/selfservice.zsh index fb189e3..d367937 100644 --- a/.config/zsh/lib/selfservice.zsh +++ b/.config/zsh/lib/selfservice.zsh @@ -16,12 +16,17 @@ z-zwc-gen() { for i ( "${ZSHU[d_conf]}"/**/*.zsh(N.r) ) ; do zcompile -UR "$i" done - for i ( "${ZSHU[d_cache]}/completion"/*(N.r) ) ; do - case "$i" in - *.zwc ) continue ;; - esac - zcompile -zUR "$i" - done + # for i ( "${ZSHU[d_completion]}"/*(N.r) ) ; do + # case "$i" in + # *.zwc ) + # # likely a remnant + # rm -f "$i" + # continue + # ;; + # esac + # zcompile -UR "$i" + # mv -f "$i.zwc" "${ZSHU[d_compzwc]}/" + # done } z-zwc-flush() { @@ -30,8 +35,7 @@ z-zwc-flush() { z-update() { dotfiles-update - z-zwc-flush - z-zwc-gen + z-cache-flush } z-reload() { @@ -42,7 +46,7 @@ z-reload() { ## reload or new session are required to regenerate compcache z-cache-flush() { - find "${ZSHU[d_cache]}/" "${ZSHU[d_compcache]}/" -xdev -type f '!' -name '.keep' -delete + find "${ZSHU[d_cache]}/" -xdev -type f '!' -name '.keep' -delete z-zwc-flush z-zwc-gen } diff --git a/.config/zsh/local/completion/.keep b/.config/zsh/local/completion/.keep new file mode 100644 index 0000000..e69de29 diff --git a/.config/zsh/rc.zsh b/.config/zsh/rc.zsh index 05ac613..cf17523 100644 --- a/.config/zsh/rc.zsh +++ b/.config/zsh/rc.zsh @@ -17,9 +17,12 @@ zshu_modules+=( zutil ) for i ( ${zshu_modules} ) ; do - [[ "$i" != */* ]] && i="zsh/$i" - zmodload -i $i -done ; unset i -unset zshu_modules + case "$i" in + */* ) ;; + * ) i="zsh/$i" ;; + esac + zmodload -i "$i" +done +unset i zshu_modules autoload -Uz +X colors && colors diff --git a/.config/zsh/rc/completion.zsh b/.config/zsh/rc/completion.zsh index 89fe299..bc2ade0 100644 --- a/.config/zsh/rc/completion.zsh +++ b/.config/zsh/rc/completion.zsh @@ -19,9 +19,9 @@ zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-dir zstyle ':completion:*:*:*:users' ignored-patterns adm amanda apache at avahi avahi-autoipd backup beaglidx bin bind cacti canna clamav colord daemon dbus distcache dnsmasq dovecot fax ftp games gdm gkrellmd gnats gopher hacluster haldaemon halt hplip hsqldb ident irc junkbust kdm ldap list lp mail mailman mailnull man messagebus mldonkey mysql nagios named netdump news nfsnobody nginx nobody nscd ntp ntpsec nut nx obsrun openvpn operator pcap polkitd postfix postgres privoxy proxy pulse pvm quagga radvd redsocks rpc rpcuser rpm rtkit saned sbuild sbws scard sddm shutdown speech-dispatcher squid sshd statd svn sync sys tcpdump tftp tss usbmux uucp uuidd vcsa wwwrun www-data x2gouser xfs '_*' 'systemd-*' 'debian-*' 'Debian-*' zstyle '*' single-ignored show -zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w" +zstyle ':completion:*:*:*:*:processes' command "ps -u ${USER} -o pid,user,comm -w -w" zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' -zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' +zstyle ':completion:*:kill:*' command 'ps -u ${USER} -o pid,%cpu,tty,cputime,cmd' if autoload -Uz +X bashcompinit ; then bashcompinit && ZSHU[compdump_bash]=1 @@ -30,10 +30,10 @@ fi autoload -Uz +X compinit && \ compinit -i -C -d "${ZSHU[f_compdump]}" -for i ( ${ZSHU[d_conf]}/completion/*.zsh(N.r) ) ; do +for i ( "${ZSHU[d_conf]}"/completion/*.zsh(N.r) ) ; do source "$i" done ; unset i -for i ( ${ZSHU[d_conf]}/local/completion/*.zsh(N.r) ) ; do +for i ( "${ZSHU[d_conf]}"/local/completion/*.zsh(N.r) ) ; do source "$i" done ; unset i diff --git a/.config/zsh/rc/keyboard.zsh b/.config/zsh/rc/keyboard.zsh index ce493b9..d5cf706 100644 --- a/.config/zsh/rc/keyboard.zsh +++ b/.config/zsh/rc/keyboard.zsh @@ -134,5 +134,5 @@ bindkey -e for i ( /usr/share/doc/fzf/examples/key-bindings.zsh ) ; do [ -s "$i" ] || continue - source "$i" + source $i done ; unset i