From be13098d1a22145602968109266ef0e07726594e Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Sat, 8 Jun 2019 01:46:40 -0700 Subject: [PATCH] borrow completions from prezto at least until i can bother to fix my own --- home/prezto-compinit | 110 +++++++++++++++++++++++++++++++++++++++++++ home/zshrc | 33 +++---------- install | 4 +- 3 files changed, 118 insertions(+), 29 deletions(-) create mode 100644 home/prezto-compinit diff --git a/home/prezto-compinit b/home/prezto-compinit new file mode 100644 index 0000000..96b1257 --- /dev/null +++ b/home/prezto-compinit @@ -0,0 +1,110 @@ +# this code comes from prezto: +# https://github.com/sorin-ionescu/prezto/blob/master/modules/completion/init.zsh + +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. +setopt AUTO_MENU # Show completion menu on a successive tab press. +setopt AUTO_LIST # Automatically list choices on ambiguous completion. +setopt AUTO_PARAM_SLASH # If completed parameter is a directory, add a trailing slash. +setopt EXTENDED_GLOB # Needed for file modification glob modifiers with compinit +unsetopt MENU_COMPLETE # Do not autoselect the first completion entry. +unsetopt FLOW_CONTROL # Disable start/stop characters in shell editor. + +# 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. +autoload -Uz compinit +_comp_files=(${ZDOTDIR:-$HOME}/.zcompdump(Nm-20)) +if (( $#_comp_files )); then + compinit -i -C +else + compinit -i +fi +unset _comp_files + +# Styles + +# Use caching to make completion for commands such as dpkg and apt usable. +zstyle ':completion::complete:*' use-cache on +zstyle ':completion::complete:*' cache-path "${ZDOTDIR:-$HOME}/.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 +zstyle ':completion:*:matches' group 'yes' +zstyle ':completion:*:options' description 'yes' +zstyle ':completion:*:options' auto-description '%d' +zstyle ':completion:*:corrections' format ' %F{green}-- %d (errors: %e) --%f' +zstyle ':completion:*:descriptions' format ' %F{yellow}-- %d --%f' +zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f' +zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f' +zstyle ':completion:*:default' list-prompt '%S%M matches%s' +zstyle ':completion:*' format ' %F{yellow}-- %d --%f' +zstyle ':completion:*' group-name '' +zstyle ':completion:*' verbose yes + +# Fuzzy match mistyped completions. +zstyle ':completion:*' completer _complete _match _approximate +zstyle ':completion:*:match:*' original only +zstyle ':completion:*:approximate:*' max-errors 1 numeric + +# Increase the number of errors based on the length of the typed word. But make +# sure to cap (at 7) the max-errors to avoid hanging. +zstyle -e ':completion:*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3>7?7:($#PREFIX+$#SUFFIX)/3))numeric)' + +# Don't complete unavailable commands. +zstyle ':completion:*:functions' ignored-patterns '(_*|pre(cmd|exec))' + +# Array completion element sorting. +zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters + +# Directories +zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} +zstyle ':completion:*:*:cd:*' tag-order local-directories directory-stack path-directories +zstyle ':completion:*:*:cd:*:directory-stack' menu yes select +zstyle ':completion:*:-tilde-:*' group-order 'named-directories' 'path-directories' 'users' 'expand' +zstyle ':completion:*' squeeze-slashes true + +# History +zstyle ':completion:*:history-words' stop yes +zstyle ':completion:*:history-words' remove-all-dups yes +zstyle ':completion:*:history-words' list false +zstyle ':completion:*:history-words' menu yes + +# Environment Variables +zstyle ':completion::*:(-command-|export):*' fake-parameters ${${${_comps[(I)-value-*]#*,}%%,*}:#-*-} + +# ... +zstyle '*' single-ignored show + +# Ignore multiple entries. +zstyle ':completion:*:(rm|kill|diff):*' ignore-line other +zstyle ':completion:*:rm:*' file-patterns '*:all-files' + +# Kill +zstyle ':completion:*:*:*:*:processes' command 'ps -u $LOGNAME -o pid,user,command -w' +zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;36=0=01' +zstyle ':completion:*:*:kill:*' menu yes select +zstyle ':completion:*:*:kill:*' force-list always +zstyle ':completion:*:*:kill:*' insert-ids single + +# Man +zstyle ':completion:*:manuals' separate-sections true +zstyle ':completion:*:manuals.(^1*)' insert-sections true + +# SSH/SCP/RSYNC +zstyle ':completion:*:(ssh|scp|rsync):*' tag-order 'hosts:-host:host hosts:-domain:domain hosts:-ipaddr:ip\ address *' +zstyle ':completion:*:(scp|rsync):*' group-order users files all-files hosts-domain hosts-host hosts-ipaddr +zstyle ':completion:*:ssh:*' group-order users hosts-domain hosts-host users hosts-ipaddr +zstyle ':completion:*:(ssh|scp|rsync):*:hosts-host' ignored-patterns '*(.|:)*' loopback ip6-loopback localhost ip6-localhost broadcasthost +zstyle ':completion:*:(ssh|scp|rsync):*:hosts-domain' ignored-patterns '<->.<->.<->.<->' '^[-[:alnum:]]##(.[-[:alnum:]]##)##' '*@*' +zstyle ':completion:*:(ssh|scp|rsync):*:hosts-ipaddr' ignored-patterns '^(<->.<->.<->.<->|(|::)([[:xdigit:].]##:(#c,2))##(|%*))' '127.0.0.<->' '255.255.255.255' '::1' 'fe80::*' diff --git a/home/zshrc b/home/zshrc index 6009f88..974b851 100644 --- a/home/zshrc +++ b/home/zshrc @@ -7,7 +7,7 @@ if [ "$SHLVL" -le 1 ] && ! expr "$TERM" : screen >/dev/null; then fi fi -setopt extended_glob +setopt extended_glob # required for various scripts in this file and otherwise local host="${(L)HOST}" fpath=(~/sh $fpath) @@ -21,34 +21,8 @@ function { autoload -Uz $f fi done - - zsc() { - local s=$1; shift - zstyle ':completion:*'$s $@ - } - zsc '*:default' list-colors '' - zsc '*' completer _complete _ignored _match _correct _approximate _prefix - zsc '*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3)))' - #zsc '*:corrections' format '%B%d (errors %e)%b' - zsc '*:default' list-prompt '%S%M matches%s' - zsc '*:default' menu select=0 - zsc '*' ignore-parents parent pwd - zsc '*' ignored-patterns '*?.sw[po]' '*?.pyc' '__pycache__' - zsc '*:*:rm:*:*' ignored-patterns - # matching: try exact, case insensitive, then partial word completion. - # ** for recursive, i think - zsc '*' matcher-list 'm:{[:lower:]}={[:upper:]}' 'r:|[._-]=** r:|=**' - # caching, for huge lists eg. package managers - zsc '*' use-cache on - zsc '*' cache-path ~/.zsh/cache - # when listing completions, show type names and group by them - zsc '*:descriptions' format "$fg_bold[black]ยป %d$reset_color" - zsc '*' group-name '' } -autoload -Uz compinit -compinit - HISTFILE=~/.histfile HISTSIZE=99999 SAVEHIST=99999 @@ -221,3 +195,8 @@ if [[ "$host" == "spectre" ]] || [[ "$host" == *"banshee" ]]; then source "$HOME/.fasd_init" alias v="f -e $EDITOR" fi + +# generated by dircolors: +export LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:' + +source ~/.prezto-compinit diff --git a/install b/install index 28cb2a9..3fc64e3 100755 --- a/install +++ b/install @@ -117,8 +117,8 @@ cd "$HOME" backup_dir="$rc/backup-$(date -u '+%s')" -for f in .bashrc .zshrc .-shrc .arrays .streamcrap .ea .vimrc \ - .inputrc .Xresources .screenrc .tmux.conf; do +for f in .bashrc .zshrc .-shrc .arrays .prezto-compinit .streamcrap .ea \ + .vimrc .inputrc .Xresources .screenrc .tmux.conf; do dotless "$f" r="$rc/home/$REPLY" hardlink "$f" "$r"