Updated select-aws-profile script to work with nushell version >= 0.94.2

Signed-off-by: necromeo <andrescheel@protonmail.com>
This commit is contained in:
unknown 2024-06-12 20:21:13 -03:00 committed by necromeo
parent 398cc82308
commit c497d09293
No known key found for this signature in database
GPG Key ID: 0F945E015DAE598A

View File

@ -9,16 +9,13 @@
#
# Usage
# select-aws-profile
export def select-aws-profile [] {
export def --env main [] {
hide AWS_REGION;
(do {
let creds = (open ($env.HOME + "/.aws/credentials") | from toml)
let selectedProfile = (for it in ($creds | transpose name creds) {
echo $it.name
})
selectedProfile = selectedProfile | str join "\n" | fzf | str trim
let profiles = $creds | transpose name creds | each {|x| printf $x.name }
let selectedProfile = $profiles | str join "\n" | fzf | str trim
if $selectedProfile != "" {
let out = {
@ -42,4 +39,4 @@ export def select-aws-profile [] {
AWS_SECRET_ACCESS_KEY: $env.AWS_SECRET_ACCESS_KEY,
AWS_REGION: $env.AWS_REGION
}
}
}