1
0
Fork 0

Zsh: Improve completions

- Clean some oh-my-zsh variables
- Move completions to the top
- Re-add functionality from oh-my-zsh:
  - Hyphen- and case-insensitive, partial-word and substring completion
  - bashcompinit
This commit is contained in:
tastytea 2022-03-25 19:38:23 +01:00
parent 4c8793e264
commit 23825215e5
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
1 changed files with 24 additions and 26 deletions

View File

@ -1,9 +1,30 @@
function() # Keep local variables in here.
{
# Initialize completions.
autoload -Uz compinit
compinit -d "${ZSH_CACHE_DIR}/.zcompdump"
############################## Completion ######################################
zmodload -i zsh/complist
autoload -Uz compinit && compinit -d "${ZSH_CACHE_DIR}/zcompdump"
setopt ALWAYS_TO_END COMPLETE_IN_WORD GLOB_COMPLETE
# Configure completions.
zstyle ':completion:*' use-cache on
zstyle ':completion::complete:*' cache-path "${ZSH_CACHE_DIR}/zcompcache"
zstyle ':completion:*' menu select
zstyle ':completion:*' completer _complete _ignored _approximate
# Next line is hyphen- and case-insensitive, partial-word and substring
# completion, copied from oh-my-zsh.
zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*' file-sort modification # access didn't work.
zstyle ':completion:complete:*' sort false # Needed for file-sort.
zstyle ':completion:complete:*:options' sort false # Don't sort command options.
zstyle ':completion:*:*:*:*:processes' \
command "ps -u $USER -o pid,user,comm,cmd -w -w"
compdef '_dispatch git git' config # git completions for config.
autoload -Uz +X bashcompinit && bashcompinit
# Directory options
setopt AUTO_CD AUTO_PUSHD PUSHD_IGNORE_DUPS PUSHD_MINUS
@ -31,13 +52,6 @@ add-zsh-hook zshaddhistory _my_import_history_zshaddhistory
############################## Plugins #########################################
# Hyphen-insensitive completion. Case sensitive completion must be off. _ and -
# will be interchangeable.
HYPHEN_INSENSITIVE="true"
# Enable command auto-correction.
ENABLE_CORRECTION="true"
# https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
export ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
@ -77,22 +91,6 @@ zstyle ':fzf-tab:complete:man:*' fzf-preview 'whatis -l $word | cut -d- -f2,3,4,
async_init
############################## Completion ######################################
setopt ALWAYS_TO_END COMPLETE_IN_WORD
# Configure completions.
zstyle ':completion::complete:*' cache-path "${ZSH_CACHE_DIR}/.zcompcache"
zstyle ':completion:*' completer _complete _ignored _approximate
zstyle ':completion:*' file-sort modification # access didn't work.
# Not sure why the next line is needed. Maybe fzf-tab is setting it to true?
zstyle ':completion:complete:*' sort false # Needed for file-sort.
zstyle ':completion:complete:*:options' sort false # Don't sort command options.
zstyle ':completion:*:*:*:*:processes' \
command "ps -u $USER -o pid,user,comm,cmd -w -w"
compdef '_dispatch git git' config # git completions for config.
################################################################################
function generate_terminfo_24bit()