zsh: Divide zshrc into zshrc.d
Move every file from plugins into zshrc.d as well as all bigger blobs in the zshrc into their own files there. Some stuff is still in there that I am not all too sure where it belongs. TODO: Move. Because all external plugins are now sourced over a symlink I had to create a fork of fzf-tab for now that supports that. See: https://github.com/Aloxaf/fzf-tab/pull/153
This commit is contained in:
47
.config/zsh/completion/_conf
Normal file
47
.config/zsh/completion/_conf
Normal file
@@ -0,0 +1,47 @@
|
||||
#compdef conf
|
||||
|
||||
## Author: druckdev
|
||||
## Created: 2020-04-19
|
||||
|
||||
local _MAX_DEPTH=2
|
||||
|
||||
local w1="${words[$#words - 1]}"
|
||||
local w2="${words[$#words - 2]}"
|
||||
local w3="${words[$#words - 3]}"
|
||||
|
||||
if [ -z $w2 ]; then # first word to complete
|
||||
# move into config directory
|
||||
pushd -q "${XDG_CONFIG_HOME:-$HOME/.config}/"
|
||||
# list all directories
|
||||
local paths="$(find -L *(-/) -maxdepth $_MAX_DEPTH -type d 2>/dev/null | xargs)"
|
||||
# move back from config directory
|
||||
popd -q
|
||||
|
||||
# move into HOME
|
||||
pushd -q "$HOME"
|
||||
# list all directories starting with a dot (but remove that dot)
|
||||
paths+="$(find -L .*~.cache(-/) -maxdepth $_MAX_DEPTH -type d 2>/dev/null | sed 's/^\.//' | xargs)"
|
||||
# move back from HOME
|
||||
popd -q
|
||||
|
||||
# use list for completion
|
||||
_multi_parts / '('"$paths"')'
|
||||
|
||||
elif [ -z $w3 ]; then # second word to complete
|
||||
# move into chosen config directory
|
||||
if [ -d "${XDG_CONFIG_HOME:-$HOME/.config}/$w1" ]; then
|
||||
pushd -q "${XDG_CONFIG_HOME:-$HOME/.config}/$w1"
|
||||
elif [ -d "$HOME/.$w1" ]; then
|
||||
pushd -q "$HOME/.$w1"
|
||||
fi
|
||||
|
||||
# check if there are any files here
|
||||
# eval "local $(echo $functions[conf] | grep CONF_PATTERNS= | sed -E 's/\$(\{?)1(\}?)/\$\1w1\2/g; s/^[ \t]*//')"
|
||||
local exist=( *(-.) ) 2>/dev/null
|
||||
|
||||
# complete (symlinks pointing to) files
|
||||
[ -z "$exist" ] || _values "config:" *(-.)
|
||||
|
||||
# move back
|
||||
popd -q
|
||||
fi
|
||||
Reference in New Issue
Block a user