aws / aws/amazon-q-developer-cli

Run commands in user's shell environment

Open
#1,030 4 comments 4 reactions 1 assignee Assigned to @brandonskiser View on GitHub
good first issue Roadmap
Dominant language
Rust
Stars
2k
Forks
439
PR merge metrics
No merged PRs in 30d

Description

## Summary
Amazon Q Chat should execute commands within the user's actual shell environment (bash, zsh, etc.) to access user-defined aliases, functions, environment variables, and other shell customizations.

## Problem Statement
Currently, Amazon Q Chat executes commands in a separate bash shell that doesn't have access to the user's shell configuration. This means:

1. Custom aliases defined in .zshrc, etc. are not available
2. User-defined shell functions cannot be used
3. Custom environment variables are not accessible
4. PATH modifications and other shell customizations are not applied

This creates a disconnect between how users work in their terminal and how Amazon Q Chat executes commands, requiring users to provide full command paths or avoid using their custom shortcuts.

## Proposed Solution
Modify Amazon Q Chat to:

1. Detect the user's default shell (bash, zsh, fish, etc.)
2. Execute commands through that shell with the user's configuration loaded
3. Preserve the shell's environment between command executions within a session

For example, when a user with zsh as their default shell asks Amazon Q to run a command like "bb" (which might be an alias for "brazil-build"), Amazon Q should:
• Execute the command through zsh
• Load the user's .zshrc configuration
• Run the command with all aliases and functions available

## Benefits
• Seamless integration with the user's existing workflow
• Reduced friction when asking Amazon Q to execute commands
• Ability to use shorthand commands and aliases familiar to the user
• Consistent environment between terminal and Amazon Q Chat

## Use Cases
1. Running aliased commands like "gt" instead of "gradle tasks"
2. Using custom functions defined in shell configuration
3. Accessing environment variables set in shell startup files
4. Utilizing modified PATH or other environment customizations

## Technical Considerations
• Security implications of executing commands in the user's shell environment
• Handling different shell types (bash, zsh, fish, etc.)
• Maintaining shell state between command executions
• Potential performance implications

## Example

When a user with an alias "describereg" for 'aws cloudformation describe-type-registration --profile default --registration-token' in their .zshrc asks:

`run describereg foobar`

Amazon Q should execute this in the user's zsh environment with their .zshrc loaded, effectively running:

`aws cloudformation describe-type-registration --profile default --registration-token foobar`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.