summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2023-08-18 16:53:00 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2023-08-30 12:42:31 -0700
commit396f21901160afd54adf21970f22f92c38006bef (patch)
treefe9c9cfdc8fd2b7d9c5c46e140d4c1936c47c5d8 /lib
parenta3ecd7efed6d667cec3ac861e854a92d759b4390 (diff)
downloadspack-396f21901160afd54adf21970f22f92c38006bef.tar.gz
spack-396f21901160afd54adf21970f22f92c38006bef.tar.bz2
spack-396f21901160afd54adf21970f22f92c38006bef.tar.xz
spack-396f21901160afd54adf21970f22f92c38006bef.zip
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 ```
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/commands.py3
1 files changed, 3 insertions, 0 deletions
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)