Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for xonsh #1018

Open
PodioSpaz opened this issue Aug 9, 2024 · 7 comments
Open

Add support for xonsh #1018

PodioSpaz opened this issue Aug 9, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request stale Will be auto-closed in 14 days
Milestone

Comments

@PodioSpaz
Copy link

Please add support for xonsh.

Currently, the eval and exec commands return fatal errors when using xonsh shell.

~
xsh ❯ aws-sso --sso=prd eval
FATAL   invalid or unsupported shell.  Please file a bug!

~
xsh ❯ aws-sso --sso=prd exec
FATAL   exec: no command

Thanks

@PodioSpaz PodioSpaz added the enhancement New feature or request label Aug 9, 2024
@synfinatic
Copy link
Owner

Hi @PodioSpaz,

Thanks for the feature request. eval command will definitely not work right now until I can add support. exec command is bailing out because xonsh doesn't set the $SHELL environment variable so without some command after exec it will fail. You can get around this by:

aws-sso --sso=prd exec xonsh or by running the specific command directly: aws-sso --sso=prd exec aws sts get-caller-identity

@synfinatic synfinatic added this to the 2.0.0 milestone Aug 9, 2024
@synfinatic
Copy link
Owner

@PodioSpaz: So I had a similar issue with fish... looks like xonsh does not set the $SHELL environment variable which per-the documentation is the default command to run for aws-sso exec and enable other features of aws-sso.

So since you're the de-facto resident xonsh expert, what is the correct/supported way to detect that a command is running inside of the xonsh shell?

@PodioSpaz
Copy link
Author

Hello @synfinatic,

As it turns out, xonsh does not have a built-in exec command.

I was able to get aws-sso exec to work by adding the following to ~/.xonshrc.

# Adding for aws-sso support
aliases['exec'] = aliases['xexec']
$SHELL = f"{$(which xonsh)}"

Additional resources on xexec:
xonsh/xonsh#84
https://xon.sh/aliases.html#exec-and-xexec

This solution does not work with https://starship.rs/

what is the correct/supported way to detect that a command is running inside of the xonsh shell?

I don't know, but I'll investigate. At the moment, the best way I know of is to test for the existence of $XONSH_VERSION

@synfinatic
Copy link
Owner

$XONSH_VERSION should work nicely.

Not sure I followed the issue about the missing exec command though? aws-sso exec is just defaulting to starting a new copy of the shell (as defined by $SHELL) and passing in the necessary environment variables so they are ready to go.

If you were to do aws-sso exec -p <profile> aws sts get-caller-identity then it ignores the $SHELL and instead run the aws command with the appropriate ENV vars set for that single command.

@synfinatic
Copy link
Owner

btw, @PodioSpaz are you willing to do the necessary shell integration to enable tab completion and the helper commands (aws-sso-profile and aws-sso-clear) You can look at the existing bash/zsh/fish code for inspiration: https://github.com/synfinatic/aws-sso-cli/tree/main/internal/helper

synfinatic added a commit that referenced this issue Aug 21, 2024
Support eval/exec commands.

Refs: #1018
synfinatic added a commit that referenced this issue Aug 21, 2024
Support eval/exec commands.

Refs: #1018
@PodioSpaz
Copy link
Author

btw, @PodioSpaz are you willing to do the necessary shell integration to enable tab completion and the helper commands (aws-sso-profile and aws-sso-clear) You can look at the existing bash/zsh/fish code for inspiration: https://github.com/synfinatic/aws-sso-cli/tree/main/internal/helper

@synfinatic,
Yes, I’ll take that on.

synfinatic added a commit that referenced this issue Aug 21, 2024
- Support eval/exec commands.
- Tweak codecov.yaml

Refs: #1018
Copy link

github-actions bot commented Sep 5, 2024

This issue is stale because it has been open for 14 days with no response
from the reporter. It will be automatically closed in 14 days from this message.

@github-actions github-actions bot added the stale Will be auto-closed in 14 days label Sep 5, 2024
@synfinatic synfinatic modified the milestones: 2.0.0, 2.1.0 Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale Will be auto-closed in 14 days
Projects
None yet
Development

No branches or pull requests

2 participants