iTranslated by AI
Sneak Peek: Making Command Lines Smarter with Microsoft AI Shell Public Preview on Mac
0. Introduction
Hello! In this article, I've tested "Microsoft AI Shell," which was announced by Microsoft in late 2024, in a Mac environment. While you might think this tool, which integrates generative AI into PowerShell, is prioritized for Windows, it actually works surprisingly well on Mac too. If you're looking to streamline your daily terminal tasks or are interested in the possibilities of AI x Command Line, please check this out!
Reference 1: Official Blog
Reference 2: Ignite 2024 Session
1. What is Microsoft AI Shell?
What is AI Shell? Overview and Features
AI Shell is a tool that provides a chat interface with Large Language Models (LLMs) within an interactive shell environment. By combining an AI assistant with traditional command-line operations, it allows you to perform tasks like command suggestions, error resolution support, and automatic script generation in a conversational format.
Announced as a public preview by Microsoft's PowerShell team in November 2024, it is still undergoing improvements. AI Shell supports Windows, macOS, and Linux. It has the potential to significantly transform the traditional CLI experience by suggesting command syntax upon request or providing solutions when error messages are pasted.
Key Components
AI Shell consists of the following components:
- aish command-based standalone interactive shell environment
- AI agent framework (allows connecting various AI models and services as agents)
- PowerShell module (a module for integrating AI Shell with PowerShell 7)
- Integration with Windows Terminal and macOS iTerm2 (side-by-side pane integration on Windows, iTerm2 recommended on Mac)
Supported Agents
AI Shell refers to each AI assistant as an "agent." The initial release includes the following two types of agents:
-
Azure OpenAI Agent
- A general-purpose AI assistant using GPT models on Azure OpenAI Service.
- Supports a wide range of tasks, such as answering natural language questions, generating code, and providing command examples.
- Connects to OpenAI's GPT-4/3.5 models by default.
- Can also connect to your own Azure OpenAI resources (fine-tuned models or dedicated endpoints) as needed.
- Allows direct use of OpenAI models using API keys provided by OpenAI.
-
Copilot in Azure Agent
- An assistant specialized for Azure.
- Enables the use of Microsoft Azure Copilot features from the CLI.
- Strong in suggesting Azure CLI and Azure PowerShell commands and assisting in the automation of Azure resource operations.
- Answers inquiries regarding Azure.
- Requires logging in via Azure CLI beforehand and assigning necessary IAM roles, such as "Copilot for Azure User," to the target account (service currently in limited preview).
- Displays usage notes and limitations for Copilot (e.g., maximum of 15 requests per chat, 10 chats per 8 hours) upon first use.
Core Features of AI Shell
AI Shell provides a chat-based UI where agents respond interactively to natural language input from the user. For example, if you ask "How do I create a text file named helloworld in PowerShell?", it will provide an appropriate New-Item command example.
A key feature of AI Shell is its framework structure that allows for the additional development of agents. Beyond the two default agents, developers can implement their own agents and integrate them into AI Shell.
In fact, contributions from the OSS community have provided agent examples for Ollama (a local LLM execution platform), and flexibility has been added to connect to other services with OpenAI-compatible APIs (e.g., LM Studio, LocalAI, Google Gemini, etc.) simply by changing settings.
In this way, AI Shell is designed as a general-purpose platform that can utilize various AI models in the background in the future.
2. Installation and Initial Setup on Mac
System Requirements
The requirements for running it on a Mac are as follows:
- macOS 13 Ventura or later
- PowerShell 7.4.6 or later (can be installed via Homebrew)
- iTerm2 (Recommended. Works with the standard Mac Terminal, but display issues may occur)
Installation Steps
If PowerShell is already installed, you can set up AI Shell with the following steps:
- Launch PowerShell and run the following command:
Invoke-Expression "& { $(Invoke-RestMethod 'https://aka.ms/install-aishell.ps1') }"
- Once the script is complete, run the
aishcommand in the terminal to verify the startup.
This completes the basic installation. On Mac, the binary is installed to /usr/local/AIShell, and the path is usually added automatically. However, if the aish command is not found, manually add the path to your .zshrc or .bash_profile.
# Example for adding to .zshrc etc.
export PATH="/usr/local/AIShell:$PATH"
API Key Configuration
To use AI Shell, you need an API key for OpenAI or Azure OpenAI. Set it up using the following steps:
- Run the
aishcommand and select "OpenAI" from the agent selection screen. - When the prompt appears, enter the
/agent configcommand. - The configuration file (usually
~/.aish/agent-config/openai-gpt/openai.agent.json) will open in an editor. - Edit and save it as follows:
{
"GPTs": [
{
"Name": "my-openai-agent",
"Description": "Personal OpenAI GPT agent",
"Endpoint": "https://api.openai.com/v1",
"Key": "Your OpenAI API key",
"ModelName": "gpt-4",
"SystemPrompt": "You are a helpful assistant specialized in PowerShell commands and programming."
}
],
"Active": "my-openai-agent"
}
- Save and close the file, then run the
/refreshcommand in AI Shell to apply the settings.
You are now ready to use the agent with OpenAI's GPT models. If you are using Azure OpenAI, change the Endpoint and Key to those of your respective Azure resource and add the deployment name to the Deployment field.
3. Key Features and Usage
Let's try some of the key features with AI Shell now that it's ready to use.
Command Generation using Natural Language
After configuring the agent, try asking for commands in natural language:
> I want to find *.log files under the current directory in PowerShell and display the top 5 sorted by size.
AI Shell will then return a response like this:
You can achieve this with the following PowerShell command:
Get-ChildItem -Path . -Filter *.log -Recurse | Sort-Object -Property Length -Descending | Select-Object -First 5 Name,Length,FullName
This command does the following:
- Get-ChildItem: Retrieves files in the current directory (.).
- -Filter *.log: Filters only files with the .log extension.
- -Recurse: Searches subdirectories recursively.
- Sort-Object: Sorts by the Length property (file size) in descending order.
- Select-Object: Retrieves only the top 5 items and displays the name, size, and full path.
If you want to execute this suggestion:
1. Entering the `/code copy` command will copy the suggested code to your clipboard.
2. Open PowerShell in another terminal tab/window, paste it, and run.
You can also ask follow-up questions. For example, if you continue by asking "I want to display the size in MB," the AI will suggest a new, improved command based on the previous one.
Switching Agents
One of the highlights of AI Shell is the ability to switch between multiple AI agents. If you want to ask an Azure-related question:
@azure What is the command to create a new resource group in Azure CLI?
By adding @azure at the beginning, you can direct your question to the Azure agent. After the response, it automatically returns to the original agent.
If you want to switch permanently:
/agent use azure
Use a command like the one above. You can check the list of available agents with /agent list.
Error Analysis Feature
There is a feature to have the AI analyze errors when they occur in PowerShell. While it can automatically integrate via the Resolve-Error cmdlet in a Windows environment, this direct integration currently does not work in a Mac environment.
However, you can get similar support by copying the error message, manually pasting it into AI Shell, and asking, "How can I resolve this error?":
> How do I resolve this error?
Access to the path '/Users/username/protected_dir' is denied.
The AI will explain the access permission issue and suggest methods such as using sudo or changing permissions.
Code and Explanation Generation
You can generate more complex scripts, not just simple commands:
> Write a simple web scraping script in Python. I want to extract headings from a specific website using BeautifulSoup.
The AI will generate a complete example of a Python script using BeautifulSoup, along with explanations for each part. You can copy the generated code using /code copy and try it out immediately.
4. Latest Updates (March 2025)
"Preview 2" was released in late February 2025, bringing several notable improvements:
Expanded Support for Third-Party LLMs
The most significant change is the support for external LLMs with OpenAI-compatible APIs. The following services are now newly supported:
- Ollama: LLM engine that runs locally
- Google Gemini: Google's generative AI
- DeepSeek: A large-scale open model
- LocalAI: A self-hosted LLM framework
- Grok: xAI's (formerly Twitter) model
- LM Studio: A local LLM management tool
This makes it possible to use AI Shell even offline (using Ollama, etc.). You can utilize various AI backends simply by changing the endpoint in the configuration file.
Enhanced Azure PowerShell Support
Azure-related features have also been strengthened:
- Improved integration with Azure PowerShell
- Authentication support via
Connect-AzAccount(previously only Azure CLI) - Addition of the
/replacecommand to interactively replace parameters within generated Azure PowerShell scripts
Other Improvements
- Native command error output can now be sent to AI in Windows environments
- Support for streaming responses, allowing you to check long answers as they are being generated
- Provision of Bicep templates for easy construction of Azure OpenAI resources
With these new features, AI Shell is evolving from a mere Microsoft product into a platform that integrates various AI models.
5. Constraints and Workarounds in Mac Environment
Compared to the Windows environment, there are some limitations on Mac. However, most of them can be addressed.
Constraint 1: No Support for Pane Splitting
In Windows, AI Shell and PowerShell are displayed side-by-side in split panes, but the Mac version does not have this feature.
Workaround:
- Manually split the screen using iTerm2's standard features, running AI Shell in one pane and PowerShell in the other.
- Develop a habit of quickly switching between tabs or windows using keyboard shortcuts.
Constraint 2: Limited PowerShell Module Integration
In Windows, automatic integration features like Resolve-Error and /code post are available through the PowerShell module, but these are limited in the Mac version.
Workaround:
- Manually copy and paste error messages.
- Use the
/code copycommand to copy code examples to the clipboard.
Constraint 3: Color Display Issues
Colors may not display correctly in the standard Mac Terminal.app, which can reduce the visibility of code blocks.
Workaround:
- Use iTerm2 (recommended).
- Copy only the necessary parts from the AI Shell response to a text editor to check them.
6. Comparison with Other Similar Tools
AI Shell is not the only AI tool for the CLI. Let's compare it with other options.
GitHub Copilot CLI
GitHub Copilot CLI (Command Line Interface), which was officially released in March 2024, also has the ability to generate commands from natural language.
Comparison points:
- Pricing: Copilot CLI is subscription-based (around $10/month), while AI Shell is free but requires an API key.
- Interactivity: Copilot CLI is more of a Q&A type, whereas AI Shell maintains conversation history.
- Immediate Execution: Copilot CLI can execute suggested commands immediately, while AI Shell (in a Mac environment) requires manual copying.
- Extensibility: AI Shell can switch between multiple LLM backends, while Copilot CLI only uses models provided by GitHub.
Recommended usage: Use Copilot CLI for one-off command generation, and AI Shell for solving complex problems through dialogue.
iTerm2 AI Features
Since late 2023, iTerm2 has also experimentally introduced ChatGPT integration (launched with ⌘+Y).
Comparison points:
- Integration: iTerm2 AI is integrated directly into the terminal app, while AI Shell is a separate process.
- Functionality: AI Shell is richer in features such as maintaining dialogue and switching agents.
- Configuration: Both require an OpenAI API key.
- Platform: iTerm2 AI is Mac-exclusive, while AI Shell is cross-platform.
Recommended usage: iTerm2 AI for a Mac-exclusive environment, and AI Shell for use across multiple environments.
Other OSS Tools
Open-source CLI AI assistant tools like ShellGPT and Shell Genie also exist.
Comparison points:
- Customization: OSS tools can be customized freely.
- Functionality: AI Shell provides more comprehensive overall features.
- Support: OSS relies on community support, while AI Shell has official Microsoft support.
- Backend: Many OSS tools also use the OpenAI API.
Recommended usage: OSS tools when you want to specialize for a specific purpose, and AI Shell if you want an all-in-one solution.
7. Actual Usage and Impact on Productivity
After using AI Shell for several weeks, I found it particularly helpful in the following scenarios.
Scenario 1: Complex Filtering
When trying to perform a multi-criteria search like "Find PDF files updated within the last week that are 1MB or larger," you would normally need to look up the appropriate options for Get-ChildItem or the find command.
In AI Shell, you can just ask the question in natural language, and as a result, the following PowerShell command was suggested:
$oneWeekAgo = (Get-Date).AddDays(-7)
Get-ChildItem -Path . -Filter *.pdf -Recurse |
Where-Object { $_.LastWriteTime -ge $oneWeekAgo -and $_.Length -ge 1MB } |
Select-Object Name, Length, LastWriteTime, FullName
I could execute this directly by copying and pasting, and since the AI adjusted the command every time I added a condition, it eliminated repetitive trial and error.
Scenario 2: Generating Boilerplate Scripts
When I needed a script to conditionally back up files from a specific folder to another location, I asked AI Shell for a "PowerShell script that creates folders by date and backs up specific types of files."
Surprisingly, it generated a fully functional script that included error handling and progress display, which was at a level where it could be used in a production environment with just a little bit of tweaking. Tasks that would have taken over an hour before were completed in 10 minutes.
Scenario 3: Error Troubleshooting
When I showed AI Shell a dependency error that occurred during npm install for Node.js, it provided not only a solution but also a detailed explanation of why the error occurred.
The error was a "version compatibility issue between packages," and a specific fix command (npm install package@specific-version --force) was suggested, saving me a significant amount of time.
Realization of Productivity Improvement
My impression after using it for a few weeks:
- Reduction in search time: Time spent searching for command options on Google was reduced by about 90%.
- Streamlining trial and error: The number of trials when assembling complex commands was reduced to about one-third.
- Learning effect: A side benefit was being able to learn new command techniques from the AI's explanations.
However, it is important not to take the AI's suggestions at face value and to always verify the content of important commands. Don't forget to validate suggested commands, especially before using them in a production environment.
8. Future Prospects and Outlook
AI Shell is still in the preview stage, but let's consider Microsoft's strategic positioning and future direction.
Relationship with Microsoft's Overall AI Strategy
Microsoft is rolling out the Copilot brand across the board, but AI Shell is being developed as its own brand rather than under the "Copilot" name. This suggests:
- It is positioned as a specialized AI for the command-line domain
- Potential for expansion as a foundational technology, such as Windows Intelligence, in the future
- The intention to develop it as an open framework distinct from Copilot
Indeed, the strengthened support for third-party LLMs in Preview 2 supports this direction.
Expected Future Evolution
Based on the development speed and announcements so far, the following developments are expected:
- Strengthened seamless integration in Mac/Linux environments
- Integration with more shell environments (bash, zsh, etc.)
- Support for creating custom AI assistants through the provision of an Agent Development Kit
- Enhanced support for private LLMs for enterprises
- Collaboration or integration with Windows Terminal Chat
As part of Microsoft's Vision 2025, there is a policy of "AI for every developer tool," and AI Shell is positioned as one of those key pieces.
9. Summary: Is AI Shell Worth Using?
Summarizing the results of testing Microsoft AI Shell:
Pros
- Intuitive interface that allows for generating commands in natural language
- Step-by-step problem solving through dialogue
- Leverage specialized knowledge by switching between multiple AI agents
- Connect with various LLMs, not just OpenAI
- Open-source, providing high transparency and allowing for community contributions
Current Challenges
- Pane splitting and automatic code integration are not yet supported in Mac environments
- There is an initial setup hurdle, such as preparing API keys
- The accuracy of responses depends on the LLM being used
- Instability and functional limitations exist due to the preview stage
Recommended For
-
Developers who use the command line daily
Especially those who frequently handle complex PowerShell or shell scripts. -
Operations staff who manage and operate Azure environments
Those looking to streamline Azure commands and Azure PowerShell. -
Those interested in AI-based interactive workflows
Those who want to shorten the cycle of "searching for commands -> execution -> error -> re-investigation." -
Those seeking a consistent experience across platforms
Developers who use both Windows and Mac and want to utilize the same AI tools.
Conclusion
Although Microsoft AI Shell is still in public preview, it already provides practical value. While it is particularly powerful in Windows environments, its basic features are fully usable on Mac as well.
If you use it with the understanding that it is a preview version, you can gain many benefits such as streamlining daily command-line tasks, reducing learning costs, and accelerating troubleshooting.
With Microsoft's continuous improvements and feedback from the community, it is expected to evolve into an even more useful tool in the future. If you haven't tried it yet, please give it a shot!
Reference Links
- Microsoft AI Shell Official GitHub
- AI Shell Documentation (Microsoft Learn)
- PowerShell Team Blog: Announcing AI Shell Preview 2
- Azure OpenAI Service Documentation
[Disclaimer]
The content of this article is based on information available at the time of writing. Product specifications and features are subject to change without notice. When making implementation decisions, it is recommended to refer to the latest official information and consult with experts as necessary.
Discussion