Code Monkey home page Code Monkey logo

powertype's Introduction

Logo

PowerType

Autocomplete for Powershell
· Request Dictionary · Request Feature · Report Bug ·

asciicast

PowerShell Gallery PowerShell Gallery GitHub license

unit tests Testspace tests Coverage Status Sonar Violations (short format)

Installation

It's not feature complete yet but if you want to try it out run the following:

Install-Module PowerType -AllowPrerelease
Enable-PowerType
Set-PSReadLineOption -PredictionSource HistoryAndPlugin -PredictionViewStyle ListView # Optional

If you now type git you should get autocompletion, the dictionary for git is far from complete and doesn't know about all commands and parameters yet.

Requirements

Ensure that you are running PowerShell 7.2 and PSReadLine 2.2.0-beta4 or newer!

Auto enable in every session

Open your PowerShell Profile by running notepad $Profile and add the following:

Enable-PowerType
Set-PSReadLineOption -PredictionSource HistoryAndPlugin -PredictionViewStyle ListView

Upgrade

Disable-PowerType
Remove-Module PowerType
Install-Module PowerType -AllowPrerelease -Force

Restart powershell

Uninstall

Disable-PowerType
Remove-Module PowerType
Uninstall-Module PowerType

Troubleshooting

Get-PowerTypeStatus # To see if the background service is running as intended
Get-PowerTypeHistory # Used to see if any suggestions caused a exception

Progress

GitHub milestone GitHub milestone GitHub milestone GitHub milestone

This project is far from done but has the aim to provide autocomplete for common cli tools like git, npm, adb, docker, dotnet, node and many more while using powershell.

Contribute

If you wish to contribute the following would be greatly appreciated

  • Give this repository a Star
  • Spread the word
  • Create a pull request with a new Dictionary (See npm for a simple example)
  • Sponsor using the button above (Only do this if you can afford it)

Acknowledgements

This is heavily inspired by Fish shell and fig autocomplete, some dictionaries are generated from the specifications in Carapace-bin big thanks to rsteube for his patience and help!

powertype's People

Contributors

anderssonpeter avatar megasware128 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

powertype's Issues

simplify conditions to constant

simplify conditions to constant when possible (no dynamic expressions are involved).

This should improve performance as conditions are evaluated many times.

Git merge should suggest local branches

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Write git merge
  2. A list of local brances should be suggested

A parameter cannot be found that matches the parameter name 'PredictionSource'

Describe the bug
Default instructions are incomplete, or there is a bug somewhere.

To Reproduce
Steps to reproduce the behavior:

Install-Module PowerType -AllowPrerelease
Enable-PowerType

Expected behavior
I expected PowerType to be enabled without throwing any errors.

Environment (please complete the following information):

  • OS: Windows 11
  • PowerShell version: 7.2.1
  • PSReadLine version: 2.2.0-beta5
  • PowerType version: 0.0.10-preview

Additional context

image

Cannot install 0.0.13-preview

Describe the bug
Installing 0.0.13-preview fails with an error about needing either Admin rights or "-Scope CurrentUser". Both are set.

Installing 0.0.12-preview works fine.

Fails both without PowerType installed and with 0.0.12 installed. In both cases PSReadLine 2.2.6 is installed (cannot easily downgrade).

To Reproduce

❯ Install-Module -Name PowerType -AllowPrerelease -Scope CurrentUser -Verbose -RequiredVersion 0.0.13-preview
VERBOSE: Acquiring providers for assembly: C:\Users\vincent.goossens\Documents\PowerShell\Modules\PackageManagement\1.4.8.1\coreclr\netstandard2.0\Microsoft.PackageManagement.NuGetProvider.dll
VERBOSE: Acquiring providers for assembly: C:\Users\vincent.goossens\Documents\PowerShell\Modules\PackageManagement\1.4.8.1\coreclr\netstandard2.0\Microsoft.PackageManagement.ArchiverProviders.dll
VERBOSE: Acquiring providers for assembly: C:\Users\vincent.goossens\Documents\PowerShell\Modules\PackageManagement\1.4.8.1\coreclr\netstandard2.0\Microsoft.PackageManagement.CoreProviders.dll
VERBOSE: Acquiring providers for assembly: C:\Users\vincent.goossens\Documents\PowerShell\Modules\PackageManagement\1.4.8.1\coreclr\netstandard2.0\Microsoft.PackageManagement.MetaProvider.PowerShell.dll
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PowerType'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'PowerType'.
VERBOSE: Performing the operation "Install-Module" on target "Version '0.0.13-preview' of module 'PowerType'".

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its
InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): a
VERBOSE: The installation scope is specified to be 'CurrentUser'.
VERBOSE: The specified module will be installed in 'C:\Users\vincent.goossens\Documents\PowerShell\Modules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'PowerType' with version '0.0.13-preview' from the repository 'https://www.powershellgallery.com/api/v2'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PowerType'' for ''.
VERBOSE: InstallPackage' - name='PowerType', version='0.0.13-preview',destination='C:\Users\vincent.goossens\AppData\Local\Temp\655688694'
VERBOSE: DownloadPackage' - name='PowerType', version='0.0.13-preview',destination='C:\Users\vincent.goossens\AppData\Local\Temp\655688694\PowerType.0.0.13-preview\PowerType.0.0.13-preview.nupkg', uri='https://www.powershellgallery.com/api/v2/package/PowerType/0.0.13-preview'
VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/PowerType/0.0.13-preview'.
VERBOSE: Completed downloading 'https://www.powershellgallery.com/api/v2/package/PowerType/0.0.13-preview'.
VERBOSE: Completed downloading 'PowerType'.
VERBOSE: InstallPackageLocal' - name='PowerType', version='0.0.13-preview',destination='C:\Users\vincent.goossens\AppData\Local\Temp\655688694'
VERBOSE: Validating the 'PowerType' module contents under 'C:\Users\vincent.goossens\AppData\Local\Temp\655688694\PowerType.0.0.13-preview' path.
VERBOSE: Test-ModuleManifest successfully validated the module manifest file 'C:\Users\vincent.goossens\AppData\Local\Temp\655688694\PowerType.0.0.13-preview'.
VERBOSE: Validating the authenticode signature and publisher of the catalog file or module manifest file of the module 'PowerType'.
VERBOSE: Catalog file 'PowerType.cat' is not found in the contents of the module 'PowerType' being installed.
VERBOSE: For publisher validation, current module 'PowerType' with version '0.0.13' with publisher name '' from root certificate authority ''. Is this module signed by Microsoft: 'False'.
VERBOSE: For publisher validation, using the previously-installed module 'PowerType' with version '0.0.12' under 'C:\Users\vincent.goossens\Documents\PowerShell\Modules\PowerType\0.0.12' with publisher name '' from root certificate authority ''. Is this module signed by Microsoft: 'False'.
VERBOSE: Checking for possible command collisions for the module 'PowerType' commands.
Install-Package: Administrator rights are required to install or update. Log on to the computer with an account that has Administrator
rights, and then try again, or install by adding "-Scope CurrentUser" to your command. You can also try running the
Windows PowerShell session with elevated rights (Run as Administrator).

Environment (please complete the following information):

  • OS: Windows 10
  • PowerShell version: 7.2.6
  • PSReadLine version: 2.2.6
  • PowerType version: 0.0.13-preview

Improve ast handeling

The current handle ling of the inpit ast is fairly basic and easily breaks.

Improve it to handle both prefix and suffix.

PowerType not usable under ArchLinux with PowerShell 7.2.6

Describe the bug
When trying to enable PowerType to use it, it emits an unsupported platform error:
Enable-PowerType: Operation is not supported on this platform.

To Reproduce
Steps to reproduce the behavior:

  1. Install-Module PowerType -AllowPrerelease
  2. Enable-PowerType

Expected behavior
To function as expected from the README.

Environment (please complete the following information):

  • OS: ArchLinux running Linux 5.19.11-arch1-1
  • PowerShell version: 7.2.6
  • PSReadLine version: 2.2.6
  • PowerType version: 0.0.13

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.6
PSEdition                      Core
GitCommitId                    7.2.6
OS                             Linux 5.19.11-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 24 Sep 2022 18:24:15 +0000
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Additional context
Using https://stackoverflow.com/a/798136 to get the error.

Inspecting the source, it faults around here:

var initialState = InitialSessionState.CreateDefault();
initialState.ThrowOnRunspaceOpenError = true;
initialState.Assemblies.Add(new SessionStateAssemblyEntry(assemblyName, assemblyPath));
initialState.ImportPSModule(modulePath);
initialState.ExecutionPolicy = ExecutionPolicy.Unrestricted;
var runspace = RunspaceFactory.CreateRunspace(initialState);
runspace.Open();

The underlying error & stack trace
PSMessageDetails      : 
Exception             : System.PlatformNotSupportedException: Operation is not supported on this platform.
                           at System.Management.Automation.Internal.SecuritySupport.SetExecutionPolicy(ExecutionPolicyScope scope, ExecutionPolicy policy, String shellId)
                           at System.Management.Automation.Runspaces.InitialSessionState.Bind(ExecutionContext context, Boolean updateOnly, PSModuleInfo module, Boolean noClobber, Boolean 
                        local, Boolean setLocation)
                           at System.Management.Automation.AutomationEngine..ctor(PSHost hostInterface, InitialSessionState iss)
                           at System.Management.Automation.Runspaces.LocalRunspace.DoOpenHelper()
                           at System.Management.Automation.Runspaces.LocalRunspace.OpenHelper(Boolean syncCall)
                           at System.Management.Automation.Runspaces.RunspaceBase.CoreOpen(Boolean syncCall)
                           at System.Management.Automation.Runspaces.RunspaceBase.Open()
                           at PowerType.BackgroundProcessing.ExecutionEngineThread.CreateRunspace() in 
                        D:\a\PowerType\PowerType\PowerType\BackgroundProcessing\ExecutionEngineThread.cs:line 99
                           at PowerType.BackgroundProcessing.ExecutionEngineThread..ctor(ThreadQueue`1 queue) in 
                        D:\a\PowerType\PowerType\PowerType\BackgroundProcessing\ExecutionEngineThread.cs:line 29
                           at PowerType.BackgroundProcessing.ExecutionEngine.Start() in D:\a\PowerType\PowerType\PowerType\BackgroundProcessing\ExecutionEngine.cs:line 29
                           at PowerType.PowerTypePredictor..ctor(ICurrentWorkingDirectoryProvider currentWorkingDirectoryProvider, IEnumerable`1 dictionaryFiles) in 
                        D:\a\PowerType\PowerType\PowerType\PowerTypePredictor.cs:line 28
                           at PowerType.EnablePowerTypePredictor.ProcessRecord() in D:\a\PowerType\PowerType\PowerType\EnablePowerTypePredictor.cs:line 56
                           at System.Management.Automation.Cmdlet.DoProcessRecord()
                           at System.Management.Automation.CommandProcessor.ProcessRecord()
TargetObject          : 
CategoryInfo          : NotSpecified: (:) [Enable-PowerType], PlatformNotSupportedException
FullyQualifiedErrorId : System.PlatformNotSupportedException,PowerType.EnablePowerTypePredictor
ErrorDetails          : 
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}



MyCommand             : Enable-PowerType
BoundParameters       : {}
UnboundArguments      : {}
ScriptLineNumber      : 1
OffsetInLine          : 1
HistoryId             : 50
ScriptName            : 
Line                  : Enable-PowerType
PositionMessage       : At line:1 char:1
                        + Enable-PowerType
                        + ~~~~~~~~~~~~~~~~
PSScriptRoot          : 
PSCommandPath         : 
InvocationName        : Enable-PowerType
PipelineLength        : 0
PipelinePosition      : 0
ExpectingInput        : False
CommandOrigin         : Internal
DisplayScriptPosition : 


00000000000000000000000000000000000000000000000000000000000000000000000000000000

TargetSite     : Void SetExecutionPolicy(Microsoft.PowerShell.ExecutionPolicyScope, Microsoft.PowerShell.ExecutionPolicy, System.String)
Message        : Operation is not supported on this platform.
Data           : {}
InnerException : 
HelpLink       : 
Source         : System.Management.Automation
HResult        : -2146233031
StackTrace     :    at System.Management.Automation.Internal.SecuritySupport.SetExecutionPolicy(ExecutionPolicyScope scope, ExecutionPolicy policy, String shellId)
                    at System.Management.Automation.Runspaces.InitialSessionState.Bind(ExecutionContext context, Boolean updateOnly, PSModuleInfo module, Boolean noClobber, Boolean local, 
                 Boolean setLocation)
                    at System.Management.Automation.AutomationEngine..ctor(PSHost hostInterface, InitialSessionState iss)
                    at System.Management.Automation.Runspaces.LocalRunspace.DoOpenHelper()
                    at System.Management.Automation.Runspaces.LocalRunspace.OpenHelper(Boolean syncCall)
                    at System.Management.Automation.Runspaces.RunspaceBase.CoreOpen(Boolean syncCall)
                    at System.Management.Automation.Runspaces.RunspaceBase.Open()
                    at PowerType.BackgroundProcessing.ExecutionEngineThread.CreateRunspace() in D:\a\PowerType\PowerType\PowerType\BackgroundProcessing\ExecutionEngineThread.cs:line 99
                    at PowerType.BackgroundProcessing.ExecutionEngineThread..ctor(ThreadQueue`1 queue) in 
                 D:\a\PowerType\PowerType\PowerType\BackgroundProcessing\ExecutionEngineThread.cs:line 29
                    at PowerType.BackgroundProcessing.ExecutionEngine.Start() in D:\a\PowerType\PowerType\PowerType\BackgroundProcessing\ExecutionEngine.cs:line 29
                    at PowerType.PowerTypePredictor..ctor(ICurrentWorkingDirectoryProvider currentWorkingDirectoryProvider, IEnumerable`1 dictionaryFiles) in 
                 D:\a\PowerType\PowerType\PowerType\PowerTypePredictor.cs:line 28
                    at PowerType.EnablePowerTypePredictor.ProcessRecord() in D:\a\PowerType\PowerType\PowerType\EnablePowerTypePredictor.cs:line 56
                    at System.Management.Automation.Cmdlet.DoProcessRecord()
                    at System.Management.Automation.CommandProcessor.ProcessRecord()

Enable customization of hint list length

Would it be possible to show more than 10 items of hints?

Maybe this could be a parameter on Enable-PowerType?

Enable-PowerType -HintCount 20

It would be nice if we could provide something like -1, which would mean "rest of the screen" which would just do as many items as the terminal screen fits.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.