0

So I am aware one can edit bash tab completion scripts with functions for a variety of behaviors

I have configured a long list of aws hosts on my .ssh/config, written as dot sepparated names, like so:

Host aws.<stack_name>.<instance_name>
    HostName X.X.X.X

by default ssh bash completion scripts display the full list of hosts declared in the config file, and this is pretty good already. But I would like to add to this behavior, which currently displays the list like so:

$ ssh aws.[tab][tab]
aws.stack1.inst1    aws.stack2.inst1
aws.stack1.inst2    aws.stack2.inst2
aws.stack1.inst3    aws.stack3.inst1
aws.stack1.inst4    aws.stack4.inst1

so that I can do the following:

$ ssh aws.[tab][tab]
stack1    stack2    stack3
$ ssh aws.stack1.[tab][tab]
inst1    inst2    inst3    inst4

But I have not been able to figure out how, and where, to add this functionality by navigating through available bash_completion scripts.

I don't want to overwrite the current ssh completion, just extend its behavior when ssh is followed by aws

How/Where can/should I implement this behavior?

Guga Figueiredo
  • 292
  • 4
  • 18
  • You could implement your completion function in a script like `complete_ssh.sh`. Then source it in your `.bashrc`. Examples of completion functions can be found in `/usr/share/bash-completion` . – builder-7000 Oct 07 '19 at 17:55
  • I was hopping to piggy back off of ssh's own scripts, is that possible? it already has a logic for config file set up, I just want to enhance that script rather than bypass it – Guga Figueiredo Oct 07 '19 at 19:42

0 Answers0