Skip to content

Shresht7/NLPowerShell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NLPowerShell

Use natural language to interact with PowerShell

Inspired by: Codex-CLI

Demonstration

Caution

Nothing is perfect! Read and verify AI-generated commands before running them. Treat them as if you found them on the internet—because they are commands from the internet. Do not run any command that you do not understand.


⭐ Features

  1. Convert Natural Language to PowerShell Commands
  2. Get an Explanation

1. Convert Natural Language to PowerShell Commands

PS> # Get a list of the 5 most CPU-intensive processes

Press Ctrl + Shift + Insert

PS> Get-Process | Sort-Object CPU -Descending | Select-Object -First 5  # Get a list of the 5 most CPU-intensive processes

Tip

NLPowerShell can leverage Get-Help or --help automatically to improve prediction accuracy

PS> git # list all tags

Press Ctrl + Ctrl + Insert

PS> git tag --list  # list all tags

2. Get an Explanation

PS> Get-Command | Get-Random | Get-Help -Full

Press Ctrl + Shift + Insert

PS> Get-Command | Get-Random | Get-Help -Full  # Retrieve a random command and display its full help information.

📦 Installation

1. Clone this repository

git clone https://github.com/Shresht7/NLPowerShell.git

or

gh repo clone Shresht7/NLPowerShell

2. Import the module

Import-Module -Name <Path\To\This\Module>

Tip

If the module is placed in $PSModulePath (either manually, by installation, or via symlink), it can be imported with Import-Module -Name NLPowerShell.

Note

Adding this import to your $PROFILE will load the module automatically when PowerShell starts. You can also Initialize-NLPowerShell straight-away with your desired configuration.

Import-Module -Name NLPowerShell
Initialize-NLPowerShell -Ollama -Model "qwen2.5-coder" -Temperature 0.2

3. Initialize the configuration

Using Ollama

Initialize-NLPowerShell -Ollama -Model "llama3.2" 

Using OpenAI

Initialize-NLPowerShell -OpenAI -Model "gpt-4" -API_KEY (Read-Host -AsSecureString -Prompt "OpenAI API Key") 

or you can read configuration from a file

Initialize-NLPowerShell -Path "Config.json"

Changing the Keybinding

Initialize-NLPowerShell -KeyBind "Ctrl+Insert"

⚙️ Configuration

To view the configuration

Get-NLPowerShellConfig

To update the configuration parameters

Set-NLPowerShellConfig -Provider Ollama -Model "llama3.2" -MaxTokens 64

To export the configuration to file

Export-NLPowerShellConfig -Path "Config.json"

or

Export-NLPowerShellConfig -Path "config.xml"

To import the configuration

Import-NLPowerShellConfig -Path "config.xml"

📖 Examples

PS> # Get a list of markdown files

Press Ctrl + Shift + Insert

PS> Get-ChildItem -Path . -Filter "*.md"    # Get a list of markdown files
PS> Get-Date

Press Ctrl + Shift + Insert

PS> Get-Date    # Get the current date

📄 License

This project is licensed under the MIT License.

About

Use natural language to interact with PowerShell

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published