A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-completion.html below:

Configuring command completion in the AWS CLI

Configuring command completion in the AWS CLI

The AWS Command Line Interface (AWS CLI) includes a bash-compatible command-completion feature that enables you to use the Tab key to complete a partially entered command. On most systems you need to configure this manually.

For information on the AWS CLI version 2 auto-prompt feature instead, see Enabling and using command prompts in the AWS CLI.

How it works

When you partially enter a command, parameter, or option, the command-completion feature either automatically completes your command or displays a suggested list of commands. To prompt command completion, you partially enter in a command and press the completion key, which is typically Tab in most shells.

The following examples show different ways that you can use command completion:

Configuring command completion on Linux or macOS

To configure command completion on Linux or macOS, you must know the name of the shell you're using and the location of the aws_completer script.

Note

Command completion is automatically configured and enabled by default on Amazon EC2 instances that run Amazon Linux.

Confirm the completer's folder is in your path

For the AWS completer to work successfully, the aws_completer needs to be in your shell's path. The which command can check if the completer is in your path.

$ which aws_completer
/usr/local/bin/aws_completer

If the which command can't find the completer, then use the following steps to add the completer's folder to your path.

Step 1: Locate the AWS completer

The location of the AWS completer can vary depending on the installation method used.

If all else fails, you can use the find command to search your file system for the AWS completer.

$ find / -name aws_completer
/usr/local/bin/aws_completer
Step 2: Identify your shell

To identify which shell you're using, you can use one of the following commands.

Step 3: Add the completer to your path
  1. Find your shell's profile script in your user folder.

    $ ls -a ~/
    .  ..  .bash_logout  .bash_profile  .bashrc  Desktop  Documents  Downloads
  2. Add an export command at the end of your profile script that's similar to the following example. Replace /usr/local/bin/ with the folder that you discovered in the previous section.

    export PATH=/usr/local/bin/:$PATH
  3. Reload the profile into the current session to put those changes into effect. Replace .bash_profile with the name of the shell script you discovered in the first section.

    $ source ~/.bash_profile
Enable command completion

After confirming the completer is in your path, enable command completion by running the appropriate command for the shell that you're using. You can add the command to your shell's profile to run it each time you open a new shell. In each command, replace the /usr/local/bin/ path with the one found on your system in Confirm the completer's folder is in your path.

After you've enabled command completion, Verify command completion is working.

Verify command completion

After enabling command completion, reload your shell, enter a partial command, and press Tab to see the available commands.

$ aws sTAB
s3              ses             sqs             sts             swf
s3api           sns             storagegateway  support
Configuring command completion on Windows

Note

For information on how PowerShell handles their completion, including their various completion keys, see about_Tab_Expansion in the Microsoft PowerShell Docs.

To enable command completion for PowerShell on Windows, complete the following steps in PowerShell.

  1. Open your $PROFILE with the following command.

    PS C:\> Notepad $PROFILE

    If you do not have a $PROFILE, create a user profile using the following command.

    PS C:\> if (!(Test-Path -Path $PROFILE ))
    { New-Item -Type File -Path $PROFILE -Force }

    For more information on PowerShell profiles, see How to Use Profiles in Windows PowerShell ISE on the Microsoft Docs website.

  2. To enable command completion, add the following code block to your profile, save, and then close the file.

    Register-ArgumentCompleter -Native -CommandName aws -ScriptBlock {
        param($commandName, $wordToComplete, $cursorPosition)
            $env:COMP_LINE=$wordToComplete
            if ($env:COMP_LINE.Length -lt $cursorPosition){
                $env:COMP_LINE=$env:COMP_LINE + " "
            }
            $env:COMP_POINT=$cursorPosition
            aws_completer.exe | ForEach-Object {
                [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
            }
            Remove-Item Env:\COMP_LINE     
            Remove-Item Env:\COMP_POINT  
    }
  3. After enabling command completion, reload your shell, enter a partial command, and press Tab to cycle through the available commands.

    $ aws sTab
    $ aws s3

    To see all available commands available to your completion, enter a partial command and press Ctrl + Space.

    $ aws sCtrl + Space
    s3              ses             sqs             sts             swf
    s3api           sns             storagegateway  support

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4