From cf8caddb9d423f2de6545c8622d383986ec72dd7 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 7 Mar 2024 11:11:40 +0200 Subject: New completion settings --- .config/zsh/lib/completion.zsh | 90 ++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 61 deletions(-) (limited to '.config') diff --git a/.config/zsh/lib/completion.zsh b/.config/zsh/lib/completion.zsh index 1686c46..7837a04 100644 --- a/.config/zsh/lib/completion.zsh +++ b/.config/zsh/lib/completion.zsh @@ -1,29 +1,19 @@ -# Auto-completion -#autoload -Uz compinit -#if [[ -n ${ZDOTDIR}/.zcompdump(#qN.mh+24) ]]; then -# compinit; -#else -# compinit -C; -#fi; - -# -# Initialization -# - -# Load and initialize the completion system ignoring insecure directories with a -# cache time of 20 hours, so it should almost always regenerate the first time a -# shell is opened each day. +#!/bin/zsh + +########## Completion(s) ########## + autoload -Uz compinit _comp_path="${XDG_CACHE_HOME:-$HOME/.cache}/zcompdump" -# #q expands globs in conditional expressions + +# Expands globs in conditional expressions if [[ $_comp_path(#qNmh-20) ]]; then - # -C (skip function check) implies -i (skip security check). - compinit -C -d "$_comp_path" + # -C (skip function check) implies -i (skip security check). + compinit -C -d "$_comp_path" else - mkdir -p "$_comp_path:h" - compinit -i -d "$_comp_path" - # Keep $_comp_path younger than cache time even if it isn't regenerated. - touch "$_comp_path" + mkdir -p "$_comp_path:h" + compinit -i -d "$_comp_path" + # Keep $_comp_path younger than cache time even if it isn't regenerated. + touch "$_comp_path" fi unset _comp_path @@ -32,23 +22,16 @@ zmodload -i zsh/complist accept-and-complete-next-history() { zle expand-or-complete-prefix } - -zstyle ':completion:*' menu select=1 - -zstyle ':completion:*:directory-stack' list-colors '=(#b) #([0-9]#)*( *)==95=38;5;12' - zle -N accept-and-complete-next-history bindkey -M menuselect '^i' accept-and-complete-next-history bindkey '^n' expand-or-complete bindkey '^p' reverse-menu-complete -zstyle ':completion:*' menu select=1 +bindkey -M menuselect '^[' undo +#zstyle ':completion:*' menu select=1 +#zstyle ':completion:*:directory-stack' list-colors '=(#b) #([0-9]#)*( *)==95=38;5;12' - -# # Options -# - setopt COMPLETE_IN_WORD # Complete from both ends of a word. setopt ALWAYS_TO_END # Move cursor to the end of a completed word. setopt PATH_DIRS # Perform path search even on command names with slashes. @@ -59,33 +42,18 @@ setopt EXTENDED_GLOB # Needed for file modification glob modifiers with c unsetopt MENU_COMPLETE # Do not autoselect the first completion entry. unsetopt FLOW_CONTROL # Disable start/stop characters in shell editor. -# # Variables -# - -# Standard style used by default for 'list-colors' LS_COLORS=${LS_COLORS:-'di=34:ln=35:so=32:pi=33:ex=31:bd=36;01:cd=33;01:su=31;40;07:sg=36;40;07:tw=32;40;07:ow=33;40;07:'} -# # Styles -# - # Defaults. zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} zstyle ':completion:*:default' list-prompt '%S%M matches%s' # Use caching to make completion for commands such as dpkg and apt usable. zstyle ':completion::complete:*' use-cache on -zstyle ':completion::complete:*' cache-path "${XDG_CACHE_HOME:-$HOME/.cache}/prezto/zcompcache" +zstyle ':completion::complete:*' cache-path "${XDG_CACHE_HOME:-$HOME/.cache}/zcompcache" -# Case-insensitive (all), partial-word, and then substring completion. -if zstyle -t ':prezto:module:completion:*' case-sensitive; then - zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' - setopt CASE_GLOB -else - zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' - unsetopt CASE_GLOB -fi # Group matches and describe. zstyle ':completion:*:*:*:*:*' menu select @@ -132,23 +100,23 @@ zstyle ':completion::*:(-command-|export):*' fake-parameters ${${${_comps[(I)-va # Populate hostname completion. But allow ignoring custom entries from static # */etc/hosts* which might be uninteresting. -zstyle -a ':prezto:module:completion:*:hosts' etc-host-ignores '_etc_host_ignores' +zstyle -a ':completion:*:hosts' etc-host-ignores '_etc_host_ignores' zstyle -e ':completion:*:hosts' hosts 'reply=( - ${=${=${=${${(f)"$(cat {/etc/ssh/ssh_,~/.ssh/}known_hosts(|2)(N) 2> /dev/null)"}%%[#| ]*}//\]:[0-9]*/ }//,/ }//\[/ } - ${=${(f)"$(cat /etc/hosts(|)(N) <<(ypcat hosts 2> /dev/null))"}%%(\#${_etc_host_ignores:+|${(j:|:)~_etc_host_ignores}})*} - ${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2> /dev/null)"}:#Host *}#Host }:#*\**}:#*\?*}} + ${=${=${=${${(f)"$(cat {/etc/ssh/ssh_,~/.ssh/}known_hosts(|2)(N) 2> /dev/null)"}%%[#| ]*}//\]:[0-9]*/ }//,/ }//\[/ } + ${=${(f)"$(cat /etc/hosts(|)(N) <<(ypcat hosts 2> /dev/null))"}%%(\#${_etc_host_ignores:+|${(j:|:)~_etc_host_ignores}})*} + ${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2> /dev/null)"}:#Host *}#Host }:#*\**}:#*\?*}} )' # Don't complete uninteresting users... zstyle ':completion:*:*:*:users' ignored-patterns \ - adm amanda apache avahi beaglidx bin cacti canna clamav daemon \ - dbus distcache dovecot fax ftp games gdm gkrellmd gopher \ - hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \ - mailman mailnull mldonkey mysql nagios \ - named netdump news nfsnobody nobody nscd ntp nut nx openvpn \ - operator pcap postfix postgres privoxy pulse pvm quagga radvd \ - rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs '_*' + adm amanda apache avahi beaglidx bin cacti canna clamav daemon \ + dbus distcache dovecot fax ftp games gdm gkrellmd gopher \ + hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \ + mailman mailnull mldonkey mysql nagios \ + named netdump news nfsnobody nobody nscd ntp nut nx openvpn \ + operator pcap postfix postgres privoxy pulse pvm quagga radvd \ + rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs '_*' # ... unless we really want to. zstyle '*' single-ignored show @@ -176,8 +144,8 @@ zstyle ':completion:*:*:mocp:*' file-patterns '*.(wav|WAV|mp3|MP3|ogg|OGG|flac): # Mutt if [[ -s "$HOME/.mutt/aliases" ]]; then - zstyle ':completion:*:*:mutt:*' menu yes select - zstyle ':completion:*:mutt:*' users ${${${(f)"$(<"$HOME/.mutt/aliases")"}#alias[[:space:]]}%%[[:space:]]*} + zstyle ':completion:*:*:mutt:*' menu yes select + zstyle ':completion:*:mutt:*' users ${${${(f)"$(<"$HOME/.mutt/aliases")"}#alias[[:space:]]}%%[[:space:]]*} fi # SSH/SCP/RSYNC -- cgit v1.2.3