Comments (3)
Hey, thank you for the kind words, glad that you find it useful!
One easy workaround about how to call private functions from any PowerShell module is the following syntax & $m {...}
- invoke scriptblock in the context of the module $m
. For example
$m = Get-Module ZLocation
$query = 'se'
& $m {Find-Matches (Get-ZLocation) $query | & $m Get-EscapedPath }
I hope that would help you build the native completers. There are native completers examples available here https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/register-argumentcompleter?view=powershell-6
from zlocation.
Hi, I tried this today, thanks for the tip.
Here is a working example for anyone who is looking for it
if (Get-Command -Name Register-ArgumentCompleter -ErrorAction Ignore) {
Register-ArgumentCompleter -CommandName 'Invoke-ExplorerZ' -ParameterName 'match' -ScriptBlock {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
# Omit first item (command name) and empty strings
$i = $commandAst.CommandElements.Count
[string[]]$query = if ($i -gt 1) {
$commandAst.CommandElements[1..($i - 1)] | ForEach-Object { $_.toString() }
}
$m = Get-Module ZLocation
& $m { param($query) Find-Matches (Get-ZLocation) $query | Get-EscapedPath } -query $query
}
}
function Invoke-ExplorerZ {
param(
[Parameter(ValueFromRemainingArguments, ValueFromPipeline = $true, Position = 0)][Object[]]$match
)
if ($null -eq $match) {
explorer.exe $pwd
return
}
$match | ForEach-Object { explorer.exe $_ }
}
Set-Alias -Name e -Value Invoke-ExplorerZ
You can now open directories in explore with tab completions
e <tab>
e C:\my-directory
Feel free to close the issue.
I haven't been able to pass the $query
properly though. Did I do something wrong there?
Edit: Fixed it, solution was to pass the $query
argument by name
& $m { param($query) Find-Matches (Get-ZLocation) $query | Get-EscapedPath } -query $query
from zlocation.
Awesome!
from zlocation.
Related Issues (20)
- It would be great to see a list of most recent HOT 2
- [Feature Request] Allow installation via Chocolatey
- Set-ZLocation and Update-ZLocation break for PS 7 if the user has defined an alias for 'find' HOT 1
- How to exclude a directory from tracking? HOT 1
- Exception calling "Add" with "2" argument(s) - issue after updating powershell to 7.1 HOT 2
- [Feature Request] z partial/path/to/dir? HOT 1
- Doesn't work with posh-git's error reporting (DollarQuestion) HOT 3
- how can I unsinstall it?thanks. HOT 1
- Database has duplicate entries differing in case only
- Cannot z to network drives HOT 1
- Invoke-ZLocation doesn't work with oh-my-posh + posh-git + ZLocation HOT 2
- Question: possible to prefer child directories? HOT 1
- [Feature request] only display directories with tab completion HOT 5
- Duplicate Unc Paths in Database Where Only One Is Updated
- ZLocation not working as intended. HOT 6
- profile file flood
- Can't jump a folder with `[` or `]` in it
- Get-FrequentFolders in ssh session is very slow HOT 3
- Unable to uninstall Zlocation HOT 1
- Path resolution is not picking the best option
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zlocation.