diff --git a/nix/oci/tanzu/default.nix b/nix/oci/tanzu/default.nix index 7ded5a9f..553c6fee 100644 --- a/nix/oci/tanzu/default.nix +++ b/nix/oci/tanzu/default.nix @@ -85,6 +85,7 @@ in "/sbin" "/usr" "/usr/local" + "/usr/share/" "/var" "/var/run" ]; @@ -207,9 +208,41 @@ in cat << 'EOF' > /home/${containerUser}/.bashrc #!/usr/bin/env bash + # Enable bash-completion + if shopt -q progcomp &>/dev/null; + then + BASH_COMPLETION_ENABLED="TRUE" + . "${pkgs.bash-completion}/etc/profile.d/bash_completion.sh" + fi + # shellcheck disable=SC1090 source <(/bin/starship init bash --print-full-init) + # Binaries with bash completions + declare -r BINS=( + clusterctl + helm + imgpkg + kapp + kctrl + kubectl + kustomize + tanzu + ytt + ) + + if [[ "''${BASH_COMPLETION_ENABLED:-FALSE}" == "TRUE" ]]; + then + echo "Loading bash completions into current shell..." + for BIN in "''${BINS[@]}"; + do + echo "Loading bash completion for ''${BIN}" + source <(''${BIN} completion bash) || { + echo "Failed to source bash completion for ''${BIN}, skipping." + } + done + fi + # Initialise the Tanzu CLI if [[ -f "''${HOME}/.config/tanzu/config.yaml" ]]; then