From c14288eac0ab7f92d757ffc52e62f4d1ba2d04fc Mon Sep 17 00:00:00 2001 From: Gal Szkolnik Date: Tue, 2 Aug 2022 07:26:18 -0400 Subject: [PATCH] =Completion support for cz alias --- _home/dot_sz.shrc.d/bash.post/99_chezmoi.complete | 2 +- _home/dot_sz.shrc.d/bash.pre/21_aliases | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/_home/dot_sz.shrc.d/bash.post/99_chezmoi.complete b/_home/dot_sz.shrc.d/bash.post/99_chezmoi.complete index 14153a4..da06e6e 100644 --- a/_home/dot_sz.shrc.d/bash.post/99_chezmoi.complete +++ b/_home/dot_sz.shrc.d/bash.post/99_chezmoi.complete @@ -1 +1 @@ -[[ -n "$BASH_COMPLETION_EXIST" && -n $(type -fP chezmoi) ]] && source <(chezmoi completion bash) +[[ -n "$BASH_COMPLETION_EXIST" && -n $(type -fP chezmoi) ]] && source <(chezmoi completion bash | add-alias-to-bash-completion-code cz ) diff --git a/_home/dot_sz.shrc.d/bash.pre/21_aliases b/_home/dot_sz.shrc.d/bash.pre/21_aliases index a4f4935..c41f21e 100644 --- a/_home/dot_sz.shrc.d/bash.pre/21_aliases +++ b/_home/dot_sz.shrc.d/bash.pre/21_aliases @@ -1,2 +1,6 @@ alias which-command="type -fP " +function add-alias-to-bash-completion-code() { + local CMD=$(printf "%s" "sed '" 's/\(complete\W.*-F\W.*chezmoi\)/\1 ' "$1/g'") + eval "$CMD" +}