{"id":13706452,"url":"https://github.com/PowerShell/UnixCompleters","last_synced_at":"2025-05-05T20:31:20.188Z","repository":{"id":40537629,"uuid":"381465734","full_name":"PowerShell/UnixCompleters","owner":"PowerShell","description":null,"archived":true,"fork":false,"pushed_at":"2022-10-26T16:38:57.000Z","size":1068,"stargazers_count":21,"open_issues_count":9,"forks_count":5,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-09-28T21:06:11.572Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PowerShell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-29T18:47:09.000Z","updated_at":"2024-09-14T02:55:48.000Z","dependencies_parsed_at":"2023-01-19T22:16:01.075Z","dependency_job_id":null,"html_url":"https://github.com/PowerShell/UnixCompleters","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerShell%2FUnixCompleters","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerShell%2FUnixCompleters/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerShell%2FUnixCompleters/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerShell%2FUnixCompleters/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PowerShell","download_url":"https://codeload.github.com/PowerShell/UnixCompleters/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224465858,"owners_count":17315886,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T22:00:56.748Z","updated_at":"2024-11-13T14:31:05.191Z","avatar_url":"https://github.com/PowerShell.png","language":"C#","funding_links":[],"categories":["C# #"],"sub_categories":[],"readme":"# Microsoft.PowerShell.UnixTabCompletion\r\n\r\nPowerShell parameter completers for native commands on Linux and macOS.\r\n\r\nThis module uses completers supplied in traditional Unix shells\r\nto complete native utility parameters in PowerShell.\r\n\r\n![Completions with apt example](completions.gif)\r\n\r\nCurrently, this module supports completions from zsh and bash.\r\nBy default it will look for zsh and then bash to run completions\r\n(since zsh's completions seem to be generally better).\r\n\r\n## Basic usage\r\n\r\nTo enable unix utility completions,\r\ninstall this module and add the following to your profile:\r\n\r\n```powershell\r\nImport-Module Microsoft.PowerShell.UnixTabCompletion\r\n```\r\n\r\nThere is also an alternate command, `Import-PSUnixTabCompletion`,\r\nthat has the same functionality but is discoverable by command completion.\r\n\r\nThis will register argument completers for all native commands\r\nfound in the usual Unix util directories.\r\n\r\nGiven the nature of native completion results,\r\nyou may find this works best with PSReadLine's MenuComplete mode:\r\n\r\n```powershell\r\nImport-Module PSUnixTabCompletion\r\n\r\nSet-PSReadLineKeyHandler -Key Tab -Function MenuComplete\r\n```\r\n\r\n## Further configuration\r\n\r\nIf you wish to set a preferred shell, you can do so by setting an environment variable:\r\n\r\n```powershell\r\n$env:COMPLETION_SHELL_PREFERENCE = 'bash'\r\n\r\n# OR\r\n\r\n$env:COMPLETION_SHELL_PREFERENCE = '/bin/bash'\r\n\r\nImport-Module PSUnixTabCompletion\r\n```\r\n\r\nNote that you must do this before you load the module,\r\nand that setting it after loading will have no effect.\r\n\r\nIf you want to change the completer after loading,\r\nyou can do so from PowerShell like so:\r\n\r\n```powershell\r\nSet-PSUnixTabCompletion -ShellType Zsh\r\n\r\n# Or if you have a shell installed to a particular path\r\nSet-PSUnixTabCompletion -Shell \"/bin/zsh\"\r\n\r\n# You can even write your own utility completer by implementing `IUnixUtilCompleter`\r\n$myCompleter = [MyCompleter]::new()\r\nSet-PSUnixTabCompletion -Completer $myCompleter\r\n```\r\n\r\nYou can retrieve the current configuration with the `Get-PSUnixTabCompletion` cmdlet:\r\n\r\n```powershell\r\nPS\u003e Get-PSUnixTabCompletion\r\n\r\nName\r\n----\r\nZshUtilCompleter\r\n```\r\n\r\n## Supporting different versions of Bash\r\n\r\n`bash` may have different tab completion depending on the version and system.\r\nTo provide greater flexibility, setting `bash` tab completion via `Set-PSUnixTabCompletion` supports an additional parameter.\r\nIf your completion script is in an alternative location,\r\nyou may provide the location of the completion script as a parameter to `Set-PSUnixTabCompletion`.\r\nBy default, this value is set to `/usr/share/bash-completion/bash_completion` which should work for most Linux systems.\r\nThis is roughly equivalent to the `source /usr/share/bash-completion/bash_completion` which may be needed by MacOS.\r\n\r\n```powershell\r\nSet-PSUnixTabCompletion -ShellType Bash -CompletionScript /usr/local/etc/bash_completion\r\n```\r\n\r\nWhen the shell is set to bash, `Get-PSUnixTabCompletion` will return the completion script.\r\n\r\n```powershell\r\n[UnixCompleters-1|main↑0↓0•0+1?2] 🐚\u003e Set-PSUnixTabCompletion -ShellType Bash -CompletionScript /usr/local/etc/bash_completion\r\n[UnixCompleters-1|main↑0↓0•0+1?2] 🐚\u003e Get-PSUnixTabCompletion\r\n\r\nCompletionScript               Name\r\n----------------               ----\r\n/usr/local/etc/bash_completion BashUtilCompleter\r\n```\r\n\r\n## Unregistering UNIX util completions\r\n\r\nThe Microsoft.PowerShell.UnixTabCompletion module will unregister completers\r\nfor all the commands it registered completers for\r\nwhen removed:\r\n\r\n```powershell\r\nRemove-Module Microsoft.PowerShell.PSUnixTabCompletion\r\n```\r\n\r\nAs with loading, there is also a convenience command provided for this:\r\n\r\n```powershell\r\nRemove-PSUnixTabCompletion\r\n```\r\n\r\n## Building the module yourself\r\n\r\nMicrosoft.PowerShell.UnixTabCompletion comes with a PowerShell build script,\r\nwhich you can invoke to build the module yourself with:\r\n\r\n```powershell\r\n./build.ps1 -Clean\r\n```\r\n\r\nThis will output the built module to `out/Microsoft.PowerShell.UnixTabCompletion`.\r\n\r\n## Credits\r\n\r\nAll the zsh completions provided by this module are made possible\r\nby the work of [@Valodim](https://github.com/Valodim)'s zsh completion project,\r\n[zsh-capture-completion](https://github.com/Valodim/zsh-capture-completion),\r\nwhich this module invokes to get completion results.\r\n\r\nThe bash completions provided by this module are adapted from the work\r\ndone by [@mikebattista](https://github.com/mikebattista) for his\r\n[PowerShell-WSL-interop](https://github.com/mikebattista/PowerShell-WSL-Interop) PowerShell module.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPowerShell%2FUnixCompleters","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPowerShell%2FUnixCompleters","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPowerShell%2FUnixCompleters/lists"}