From 396f21901160afd54adf21970f22f92c38006bef Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Fri, 18 Aug 2023 16:53:00 -0700 Subject: completion: add alias handling Bash completion is now smarter about handling aliases. In particular, if all completions for some input command are aliased to the same thing, we'll just complete with that thing. If you've already *typed* the full alias for a command, we'll complete the alias. So, for example, here there's more than one real command involved, so all aliases are shown: ```console $ spack con concretise concretize config containerise containerize ``` Here, there are two possibilities: `concretise` and `concretize`, but both map to `concretize` so we just complete that: ```console $ spack conc concretize ``` And here, the user has already typed `concretis`, so we just go with it as there is only one option: ```console spack concretis concretise ``` --- lib/spack/spack/cmd/commands.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/spack/spack/cmd/commands.py b/lib/spack/spack/cmd/commands.py index 61be25f036..9ebaa62239 100644 --- a/lib/spack/spack/cmd/commands.py +++ b/lib/spack/spack/cmd/commands.py @@ -812,6 +812,9 @@ def bash(args: Namespace, out: IO) -> None: parser = spack.main.make_argument_parser() spack.main.add_all_commands(parser) + aliases = ";".join(f"{key}:{val}" for key, val in spack.main.aliases.items()) + out.write(f'SPACK_ALIASES="{aliases}"\n\n') + writer = BashCompletionWriter(parser.prog, out, args.aliases) writer.write(parser) -- cgit v1.2.3-60-g2f50