Skip to content

Commit c18ebf5

Browse files
committed
Add wildcard search to match any portion of command
Update readme
1 parent b624467 commit c18ebf5

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

.vscode/launch.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "PowerShell: Attach to PowerShell Host Process",
9+
"type": "PowerShell",
10+
"request": "attach",
11+
"runspaceId": 1
12+
}
13+
]
14+
}

README.md

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
# Autocomplete script for sfdx on windows powershell
22

3-
### Also works on powershell core
3+
### Also works in powershell core
44

55
![](media/autocomplete.gif)
66

77
### Requirements
8+
89
- sfdx
910
- powershell (regular or powershell core)
1011

11-
### Copy this script file (sfdx-autocomplete.ps1) to any directory on your machine. Add a reference to the script in your profile.ps1. Refer to the link below for instructions on how to create your custom powershell profile
12+
### Copy this script file (sfdx-autocomplete.ps1) to any directory on your machine. Add a reference to the script in your profile.ps1. Refer to the link below for instructions on how to create your custom powershell profile
13+
1214
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7
1315

14-
### Working
15-
### Type in 'sfdx' followed by any portion of the command you're looking for in part or full. It will cycle through all commands that contain the string, in alphabetical order
16+
### How to use
17+
18+
- Type in 'sfdx' followed by any portion of the command you're looking for. For eg: Type in `sfdx` followed by a space and `lightning` to see all `force:lightning` commands, or `test` to see all commands associated with running tests.
19+
- After you type in a command, add double hyphens (`--`) followed by `<TAB><TAB>` to see the list of flags associated with the command, that you can then tab through.
1620

21+
### Note:
1722

18-
<sup><sub>The script creates a 'command.sfdx' file in your home directory each time a powershell session is started. This file contains all the sfdx commands. It is created in the background to avoid blocking the user. So, you might experience a slight delay in autocomplete to start working the very first time</sup></sub>
23+
- For the autocomplete effect seen in the gif above, add the following line to your powershell profile
24+
```js
25+
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete
26+
```
27+
- The script creates a '.sfdxcommands.json' file in your home directory each time a powershell session is started. This file contains all the sfdx commands. It is created in the background to avoid blocking the user. So, you might experience a slight delay in autocomplete to start working the very first time you install this script.

sfdx-autocomplete.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ $scriptBlock = {
3636
}
3737
elseif ($commandAst.CommandElements.Count -eq 2 -and $wordToComplete -ne "") {
3838
<# Completing a command #>
39-
$commandPattern = "^(force:)?" + $commandAst.CommandElements[1].Value + ".+" <# Complete if force: is not specified too #>
39+
$commandPattern = ".*" + $commandAst.CommandElements[1].Value + ".*" <# Complete if force: is not specified too #>
4040
$script:sfdxCommands | Where-Object id -match $commandPattern | ForEach-Object {
4141
[System.Management.Automation.CompletionResult]::new($_.id, $_.id, 'Method', $_.description)
4242
}

0 commit comments

Comments
 (0)