aws-sso-cli icon indicating copy to clipboard operation
aws-sso-cli copied to clipboard

nushell support for shell-helpers

Open b0lle opened this issue 1 year ago • 2 comments

Is your feature request related to a problem? Please describe. It would be great to add nushell support for shell-helpers

Additional context Nushell is a modern shell. aws-sso-cli could be a nice replacement for the oh-my-zsh aws plugin, which obviously does not work in nushell.

b0lle avatar Dec 29 '24 00:12 b0lle

@b0lle: Lots of shells out there and while I'm sure nushell is awesome, I've honestly never heard of it which makes this a low priority for me. If someone provides a pull request to add the shell helper code, that would help a lot and dramatically improve the chances this happens.

synfinatic avatar Dec 31 '24 00:12 synfinatic

Here's how I hacked it into nushell:

#!/usr/bin/env nu

def --env aws-sso-profile [
    profile: string
] {
    let _args = (if ($env.AWS_SSO_HELPER_ARGS? | is-empty) { '-L error' } else { $env.AWS_SSO_HELPER_ARGS })
    if ($env.AWS_PROFILE? | is-not-empty) {
        print "Unable to assume a role while AWS_PROFILE is set"
        return 1
    }

    XONSH_VERSION=1 aws-sso eval -p $profile | lines | parse "${name} = '{value}'" | reduce -f {} {|it, acc| $acc | upsert $it.name $it.value} | load-env

    if ($env.AWS_SSO_PROFILE? != $profile) {
        return 1
    }
}

def --env aws-sso-clear [] {
    let _args = (if ($env.AWS_SSO_HELPER_ARGS? | is-empty) { '-L error' } else { $env.AWS_SSO_HELPER_ARGS })
    if ($env.AWS_SSO_PROFILE? | is-empty) {
        print "AWS_SSO_PROFILE is not set"
        return 1
    }

    for row in (XONSH_VERSION=1 aws-sso eval -c | lines | parse "del ${name}") { hide-env $row.name }
}

radahh-rest avatar Aug 05 '25 04:08 radahh-rest