mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
48 lines
1.9 KiB
Bash
48 lines
1.9 KiB
Bash
# http://zsh.sourceforge.net/Doc/Release/Completion-System.html
|
|
# https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/completion.zsh
|
|
|
|
# load fancier completion menu which (most notably) supports `list-colors`
|
|
zmodload zsh/complist
|
|
zstyle ':completion:*' menu select
|
|
# show even more completion results
|
|
zstyle ':completion:*' verbose yes
|
|
|
|
zstyle ':completion::complete:*' use-cache yes
|
|
zstyle ':completion::complete:*' cache-path "$ZSH_CACHE_DIR"
|
|
|
|
# group completion result based on their categories
|
|
zstyle ':completion:*' group-name ''
|
|
# format for displaying category names
|
|
zstyle ':completion:*:descriptions' format '%F{yellow}[%d]%f'
|
|
|
|
# Sometimes zsh completion authors for whatever reason add descriptions for
|
|
# option values, but don't do describe the options themselves (e.g. ffmpeg,
|
|
# some options for GCC). In such cases description of an option can be inferred
|
|
# from the description of its value. That's the purpose of `auto-description`.
|
|
zstyle ':completion:*:options' auto-description '%d'
|
|
|
|
# case insensitive (all), partial-word and substring completion
|
|
zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*'
|
|
|
|
zstyle ':completion:*' list-dirs-first yes
|
|
# complete . and .. directories
|
|
# This is very useful when I just want to quickly look around inside a
|
|
# directory without running `ls`
|
|
zstyle ':completion:*' special-dirs yes
|
|
|
|
if [[ -n "$LS_COLORS" ]]; then
|
|
zstyle ':completion:*' list-colors "${(@s.:.)LS_COLORS}"
|
|
fi
|
|
|
|
zstyle ':completion:*:processes' command "ps xo pid,user,cmd"
|
|
zstyle ':completion:*:processes-names' command "ps xho comm="
|
|
zstyle ':completion:*:processes' force-list always
|
|
|
|
_completion_get_hosts() {
|
|
print localhost
|
|
if [[ -f ~/.ssh/config ]]; then
|
|
awk "match(\$0, /^Host[[:blank:]]*/) { print substr(\$0, RLENGTH+1); }" ~/.ssh/config
|
|
fi
|
|
}
|
|
zstyle -e ':completion:*:hosts' hosts 'reply=("${(@f)$(_completion_get_hosts)}")
|
|
'
|