zsh-bash-completions-fallback
zsh-bash-completions-fallback copied to clipboard
bash-completions-getter.sh: line 178: _completion_loader: command not found
I'm trying to make this work on NixOS and I'm getting the following error:
/nix/store/0ibqj2ysg8602by5azn2rgm64w6gmsnd-source/bash-completions-getter.sh: line 178: _completion_loader: command not found
It seems that when bash is run in non-interactive mode, this function is not defined on NixOS. I can resolve the issue with the following change, but I'm not sure how generic it is and whether it would work on other distributions.
diff --git a/zsh-bash-completions-fallback.plugin.zsh b/zsh-bash-completions-fallback.plugin.zsh
index 61402cb..4609ff9 100644
--- a/zsh-bash-completions-fallback.plugin.zsh
+++ b/zsh-bash-completions-fallback.plugin.zsh
@@ -12,7 +12,7 @@ function _bash_completions_fallback_completer {
ZSH_WORDBREAKS="$WORDCHARS" \
ZSH_WORDS="${words[@]}" \
ZSH_CURRENT=$((CURRENT-1)) \
- bash -c \
+ bash -i -c \
"source ${_bash_completions_getter_path}; get_completions")}");
local -a -U bopts=("${(ps: :)${(@f)out:0:1}}");
@@ -83,7 +83,7 @@ function _bash_completions_fetch_supported_commands {
if [ -n "${ZSH_BASH_COMPLETIONS_FALLBACK_LOAD_NATIVE_COMPLETIONS-:true}" ]; then
local out=("${(u@f)$( \
- bash -c \
+ bash -i -c \
"source ${_bash_completions_getter_path}; get_defined_completions")}");
_bash_completions_commands+=($out)
fi
well, it would likely work in other platforms, but indeed will make things slower (depending on your default default .bashrc
)
Maybe, can you try if instead you can just try to ensure that a function defined in /usr/share/bash-completion/bash_completion
(or well yours) exists and in such case source it? Would be that enough?
Otherwise, something else we could probably do for everyone is something like this:
env HOME="/tmp/fooo" DEFAULT_HOME="$HOME" bash -i -c "export HOME=$DEFAULT_HOME; echo do stuff in $HOME"
So that we won't ever end up loading the user's .bashrc
, but we still be using its HOME for other stuff.
Mh, loading the bash_completion is actually already happening, so what I assume is that we're picking the wrong location in your setup. Where is the bash_completion
script?
I assume you've to fix source_bash_completion
function in bash-completions-getter.sh
instead, can you maybe do a PR?