From 7b4696b3a6728bfb0458c5518640976c2a541faf Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Thu, 24 Jun 2021 22:08:32 +0200 Subject: [PATCH] config/shell: adjust completions & add edcomp --- .config/shell/arch | 1 + .config/shell/functions | 7 +++++++ .config/zsh/completion/_edbin | 4 +++- .config/zsh/completion/_yc | 5 +++++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .config/zsh/completion/_yc diff --git a/.config/shell/arch b/.config/shell/arch index 5837763..4b26f8d 100644 --- a/.config/shell/arch +++ b/.config/shell/arch @@ -32,6 +32,7 @@ yas() { cmd="yay -S --nobatchinstall $pkg" print -s "$cmd" eval "$cmd" + rehash fi } yar() { diff --git a/.config/shell/functions b/.config/shell/functions index 7bb4b94..8782190 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -78,6 +78,13 @@ edconf() { CONFIG_SHELL_FUNCTIONS="${BASH_SOURCE[0]:-${(%):-%x}}" alias r="reset && exec zsh" +edcomp() { + file=$(echo "$1" | sed 's/^\([^_]\)/_\1/') + $EDITOR "${fpath[-1]}/$file" + unfunction "$file" && compinit +} +compdef "_files -W ${fpath[-1]}/" edcomp + edshell() { case $1 in ("") file="$CONFIG_SHELL_FUNCTIONS";; diff --git a/.config/zsh/completion/_edbin b/.config/zsh/completion/_edbin index 0887e1a..82270b7 100644 --- a/.config/zsh/completion/_edbin +++ b/.config/zsh/completion/_edbin @@ -1,2 +1,4 @@ #compdef edbin -compadd $(ls -pA $HOME/.local/bin/scripts) #$(echo $PATH | cut -d':' -f1 | xargs ls -pA) +_files -W $HOME/.local/bin/scripts +#compadd $(ls --almost-all --indicator-style=slash $HOME/.local/bin/scripts) +#$(echo $PATH | cut -d':' -f1 | xargs ls -pA) diff --git a/.config/zsh/completion/_yc b/.config/zsh/completion/_yc new file mode 100644 index 0000000..d29a814 --- /dev/null +++ b/.config/zsh/completion/_yc @@ -0,0 +1,5 @@ +#compdef yc +compadd $(git diff-index HEAD --name-only --relative=${XDG_CONFIG_HOME/$HOME\/}/) +#_files -W $XDG_CONFIG_HOME -g "git*" +# xargs _files -W $XDG_CONFIG_HOME -g +# yadm diff HEAD --name-only -- $XDG_CONFIG_HOME