Skip to content

Commit

Permalink
Add directory argument to Set-LocationFuzzyEverything()
Browse files Browse the repository at this point in the history
This allows setting an initial directory filter on what Search-Everything
returns, making it more versatile as it allows starting the search in
another directory than the current one and makes it a much faster alternative
to Invoke-FuzzySetLocation: for a directory with about 10000 subdirectories,
`cde somedir` is instant while `fd somedir` takes 10 seconds.
  • Loading branch information
stinos authored and kelleyma49 committed Mar 31, 2017
1 parent 45ff787 commit 5bfa6ad
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
9 changes: 8 additions & 1 deletion PSFzf.Functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,16 @@ Set-Alias -Name fd -Value Invoke-FuzzySetLocation
if (Get-Command Search-Everything -ErrorAction SilentlyContinue) {
#.ExternalHelp PSFzf.psm1-help.xml
function Set-LocationFuzzyEverything() {
param($Directory=$null)
if ($Directory -eq $null) {
$Directory = $PWD.Path
$Global = $False
} else {
$Global = $True
}
$result = $null
try {
Search-Everything -FolderInclude @('') | Invoke-Fzf | ForEach-Object { $result = $_ }
Search-Everything -Global:$Global -PathInclude $Directory -FolderInclude @('') | Invoke-Fzf | ForEach-Object { $result = $_ }
} catch {

}
Expand Down
25 changes: 24 additions & 1 deletion docs/Set-LocationFuzzyEverything.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Sets the current location based on the Everything database.
## SYNTAX

```
Set-LocationFuzzyEverything
Set-LocationFuzzyEverything [-Directory <string>]
```

## DESCRIPTION
Expand All @@ -25,7 +25,30 @@ Launches fzf and sets the current location based on the user selection.
Set-LocationFuzzyEverything
```

### Launch Set-LocationFuzzyEverything specifying a path filter

Launches fzf for all subdirectories of c:\Windows and sets the current location based on the user selection.


```
Set-LocationFuzzyEverything c:\Windows
```

## PARAMETERS
### -Directory
The path to a directory that contains the subdirectories that the user will choose from.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet does not support common parameters.
Expand Down

0 comments on commit 5bfa6ad

Please sign in to comment.