mise: add bash completion to bash integration
The bash integration previously only ran `mise activate bash`, so tab completion for `mise` was never set up. Source the generated completion script via `mise completion bash --include-bash-completion-lib`; the flag self-bundles the bash-completion helpers so it also works on systems whose bash-completion predates `_comp_initialize`. Fixes #8539
This commit is contained in:
@@ -111,9 +111,17 @@ in
|
||||
};
|
||||
|
||||
programs = {
|
||||
bash.initExtra = mkIf (cfg.enableBashIntegration && cfg.package != null) ''
|
||||
eval "$(${getExe cfg.package} activate bash)"
|
||||
'';
|
||||
bash.initExtra =
|
||||
let
|
||||
# TODO: Upstream to nixpkgs
|
||||
bashCompletion = pkgs.runCommand "mise-bash-completion.bash" { } ''
|
||||
${getExe cfg.package} completion bash --include-bash-completion-lib > $out
|
||||
'';
|
||||
in
|
||||
mkIf (cfg.enableBashIntegration && cfg.package != null) ''
|
||||
eval "$(${getExe cfg.package} activate bash)"
|
||||
source ${bashCompletion}
|
||||
'';
|
||||
|
||||
zsh.initContent = mkIf (cfg.enableZshIntegration && cfg.package != null) ''
|
||||
eval "$(${getExe cfg.package} activate zsh)"
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
{ config, ... }:
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
programs = {
|
||||
mise = {
|
||||
package = config.lib.test.mkStubPackage { name = "mise"; };
|
||||
package = pkgs.writeShellScriptBin "mise" ''
|
||||
if [ "$1" = "completion" ]; then
|
||||
echo "complete -F _mise mise"
|
||||
fi
|
||||
'';
|
||||
enable = true;
|
||||
enableBashIntegration = true;
|
||||
};
|
||||
@@ -12,5 +16,7 @@
|
||||
|
||||
nmt.script = ''
|
||||
assertFileRegex home-files/.bashrc 'eval "$(/nix/store/.*mise.*/bin/mise activate bash)"'
|
||||
assertFileRegex home-files/.bashrc \
|
||||
'^source /nix/store/[0-9a-z]*-mise-bash-completion.bash$'
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user