From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9439 invoked by alias); 24 Aug 2017 01:14:23 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41591 Received: (qmail 25840 invoked by uid 1010); 24 Aug 2017 01:14:23 -0000 X-Qmail-Scanner-Diagnostics: from mx.spodhuis.org by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(94.142.241.89):SA:0(-4.2/5.0):. Processed in 2.103729 secs); 24 Aug 2017 01:14:23 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: zsh-workers+phil.pennock@spodhuis.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=spodhuis.org; s=d201708; h=Content-Type:MIME-Version:Message-ID:Subject:To: From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=R1YOqB/Pv+pfsysuc6hlTXAaoZ8DlI1lXWArvkbiucQ=; b=jIQySjSn5F7IT3eIU2aMpg5Nsg ehdfuf7NI54qWD+vyqVYyu5QwC6axWupD7NHVbMRGuUDuC4TwUWIz2nOD9iX4BrPcZATQmFqxb+pJ C5iV9FMvMGDPulQolh0sZbAVpHmjVVf4wFssOXluIdZuPmr4CK+NgPetymUgCyCfCmyes50cEfJ1s WQ0GLvu8aA+InbrGTANY0joCVyLo; Date: Wed, 23 Aug 2017 21:14:13 -0400 From: Phil Pennock To: zsh-workers@zsh.org Subject: [completion file] AWS profiles Message-ID: <20170824011413.GA41493@tower.spodhuis.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline OpenPGP: url=https://www.security.spodhuis.org/PGP/keys/0x4D1E900E14C1CC04.asc Various tools working with AWS honor a common set of environment variables for defining access. One of those is `AWS_PROFILE`, which points to a name which is used for looking up various other values. Profiles can be defined in ~/.aws/config in sections `[profile FOO]` or in ~/.aws/credentials in sections `[FOO]` (notice dropped keyword). For me, I always want the credentials file entries, because with a reasonable `[default]` section you don't need per-profile entries in the config file. This is what I'm using and it might be suitable for inclusion with zsh? Any improvements? -------------------------8< _aws_credentials >8------------------------- #compdef -value-,AWS_PROFILE,-default- local expl _wanted awscredentials expl 'AWS credentials profile name' \ compadd "$@" - ${${${(Mo)${(f)"$(<${AWS_SHARED_CREDENTIALS_FILE:-$HOME/.aws/credentials})"}##\[*\]}#\[}%\]} -------------------------8< _aws_credentials >8------------------------- Use in conjunction with: zstyle ':completion:*' fake-parameters \ AWS_PROFILE AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY \ AWS_DEFAULT_REGION AWS_SHARED_CREDENTIALS_FILE for a better AWS-using experience.