vors / zlocation Goto Github PK
View Code? Open in Web Editor NEWZLocation is the new Jump-Location
License: MIT License
ZLocation is the new Jump-Location
License: MIT License
The clipping below is unfortunate:
z
Name Value
---- -----
C:\Users\Keith 49
C:\Users\Keith\GitHub 2
C:\Users\Keith\GitHub\dahlb... 6
C:\Windows\System32 13
C:\Users\Keith\Code\electro... 16
C:\Users\Keith\Code\electro... 26
Maybe you could just switch the default order Name and Value e.g.:
z | ft Value,Name
Value Name
----- ----
52 C:\Users\Keith
2 C:\Users\Keith\GitHub
6 C:\Users\Keith\GitHub\dahlbyk\posh-git
13 C:\Windows\System32
16 C:\Users\Keith\Code\electron-app\dist
26 C:\Users\Keith\Code\electron-app
ZLocation seems to be having problems with PowerShell 5 Production Preview. It is, in some cases, unable to jump given just a number.
PS> mkdir 7\test
PS> cd 7\test
PS> cd ..\..
PS> Get-ZLocation
Name Value
------ ----
1 C:\temp
3 C:\temp\7\test
PS> z 7
WARNING: Cannot find matching location
It does work again if the folder with the number is in the jumpstats
PS> cd 7
PS> cd ..
PS> Get-ZLocation
Name Value
------ ----
1 C:\temp
3 C:\temp\7\test
4 C:\temp\7
PS> z 7
PS: Jump-Location has the same issue
run tests
Invoke-PSake
prompt should be the same
PS /Users/vors/dev/ZLocation>
prompt is broken
PS>
i have a folder that i was spending a lot of time in called
C:\blah\blah\billing-warehouse-microservice
i have another folder callled C:\blah\blah\reload scripts
if i do z re
or even z r
it should priorize the reload scripts folder IMO over the other folder where it is finding re
in the middle of the waREhouse. Even tho i was spending more time in that folder.
(jump-location seemed to do this)
Recently installed on new computer. Zlocation knows locations and will change directory with a short version of the directory name but won't do intellisense from the list of locations
There was no warning in the documentation that all my saved locations would be gone after updating from version 0.1.0 to version 0.3.0.
Immediately prior to update, my shell showed:
[ZLocation] knows about 57 locations.
After updating and starting a new shell, I see this:
[ZLocation] knows about 0 locations.
PS C:> ipmo ZLocation
WARNING: ZLocation Pipe become broken :( ZLocation is now self-disabled.
You need to restart all PowerShell instances to re-enable ZLocation.
Please continue your work and do it, when convinient.
You can report the problem on https://github.com/vors/ZLocation/issues
Should be:
WARNING: Because ZLocation pipe broke, ZLocation disabled itself. To re-enable ZLocation, restart all PowerShell instances. You can continue your work and do it when convenient. To report the problem, use https://github.com/vors/ZLocation/issues.
Maybe not needed if we will implement #4
Current weight function provide ridiculously high weight for folders, if user just lock machine for a day.
Suggested by Lee Holmes
I first tried an Update-Module and i got a bunch of errors - so then i removed all references to zlocation from my profile and removed the module,, then reinstalled 1.0 and put my $profile back
i get the following errors from the Import/ and the Zlocation knows about x Locations line:
Import-Module : The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
At ...s\WindowsPowerShell\Modules\ZLocation\1.0.0\ZLocation.psm1:5 char:1
+ Import-Module "$PSScriptRoot\ZLocation.Service.psd1"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-Module], FileLoadException
+ FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
At ...\WindowsPowerShell\Modules\ZLocation\1.0.0\ZLocation.Storage.psm1:3 char:1
+ Import-Module (Join-Path $PSScriptRoot 'ZLocation.Service.psd1')
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-Module], FileLoadException
+ FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.ImportModuleCommand
Get-ZService : The term 'Get-ZService' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At ...\WindowsPowerShell\Modules\ZLocation\1.0.0\ZLocation.Storage.psm1:8 char:16
+ $service = Get-ZService
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-ZService:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
You cannot call a method on a null-valued expression.
At ...\WindowsPowerShell\Modules\ZLocation\1.0.0\ZLocation.Storage.psm1:10 char:23
+ foreach ($item in $service.Get())
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
(i redacted some of the paths)
I'm noticing two different types of references to the imports
Import-Module (Join-Path $PSScriptRoot 'ZLocation.Service.psd1')
Import-Module "$PSScriptRoot\ZLocation.Service.psd1"
the files in Documents\WindowsPowerShell\Modules\ZLocation\1.0.0
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 9/10/2018 6:46 AM LiteDB
-a---- 9/8/2018 12:02 PM 297 ZLocation.LiteDB.psd1
-a---- 9/8/2018 12:02 PM 1378 ZLocation.LiteDB.psm1
-a---- 9/8/2018 12:02 PM 3434 ZLocation.psd1
-a---- 9/8/2018 12:02 PM 4706 ZLocation.psm1
-a---- 9/8/2018 12:02 PM 3225 ZLocation.Search.psm1
-a---- 9/8/2018 12:02 PM 390 ZLocation.Service.psd1
-a---- 9/8/2018 12:02 PM 2993 ZLocation.Service.psm1
-a---- 9/8/2018 12:02 PM 1012 ZLocation.Storage.psm1
Set-ZLocation .. returns 'Warning: Cannot find matching location"
Today I started getting an error when I try to jump to a location:
Exception calling "Add" with "2" argument(s): "Item has already been added. Key in dictionary:
'C:\temp\foo' Key being added: 'C:\Temp\foo'"
At <....>\Modules\ZLocation\1.0.0\ZLocation.Storage.psm1:12 char:9
+ $hash.add($item.path, $item.weight)
It looks like the case difference (C:\Temp vs C:\temp) may be causing an issue?
If I have directory c:\A but I have never visited it yet, calling z c:\A fails saying that it cannot find a matching location
after a day or so of using ZLocation, I start to get this error:
C:\Users\whatever\AppData\Roaming\Local\tempz auto
Exception calling "ToObject" with "2" argument(s): "Unable to cast object of type 'LiteDB.ObjectId' to type 'System.String'."
At C:\Program Files\PowerShell\Modules\ZLocation\1.0.0\ZLocation.LiteDB.psm1:15 char:5
+ ,$mapper.ToObject($type, $obj)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidCastException
When I go and look at z-location.db, I see, along with the normal entries, an entry like this:
[
{
"_id": {"$oid": "5ba9f338cfbf5e28a8f1314c"},
"weight": 1.0
}
]
If I remove that from the db, things work again. (Until a day or so later when I get the error again)
Installed successfully and works with regular powershell, but when using cmder I get this error:
Cannot write to function prompt because it is read-only or constant.
At C:\Users\MJ2\Documents\WindowsPowerShell\Modules\ZLocation\0.3.0\ZLocation.psm1:56 char:9
+ $function:prompt = [ScriptBlock]::Create($newPrompt)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (prompt:String) [], SessionStateUnauthorizedAccessException
+ FullyQualifiedErrorId : FunctionNotWritable
It would be nice to install the updated functionality with install-module
rather than having to git clone the repo. :-)
λ ~ z oper
Add-Type : (0) : 'c:\Users\tyler.thrailkill\AppData\Local\Temp\CSC8A531E0BAE344D8CAACE866C2CDDC050.TMP' is not a valid Win32 resource file
(1) : using System;
At C:\Program Files\WindowsPowerShell\Modules\ZLocation\0.1.0\ZLocation.Storage.psm1:68 char:42
+ ... e-Command { Add-Type -ReferencedAssemblies System.ServiceModel -TypeD ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (error CS1583: '...2 resource file:CompilerError) [Add-Type], Exception
+ FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand
Add-Type : Cannot add type. Compilation errors occurred.
At C:\Program Files\WindowsPowerShell\Modules\ZLocation\0.1.0\ZLocation.Storage.psm1:68 char:42
+ ... e-Command { Add-Type -ReferencedAssemblies System.ServiceModel -TypeD ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Add-Type], InvalidOperationException
+ FullyQualifiedErrorId : COMPILER_ERRORS,Microsoft.PowerShell.Commands.AddTypeCommand
New-Object : Cannot find type [System.ServiceModel.ChannelFactory`1[[ZLocation.IService]]]: verify that the assembly containing this type is loaded.
At C:\Program Files\WindowsPowerShell\Modules\ZLocation\0.1.0\ZLocation.Storage.psm1:27 char:24
+ ... peFactory = New-Object -TypeName 'System.ServiceModel.ChannelFactory` ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\ZLocation\0.1.0\ZLocation.Storage.psm1:31 char:9
+ $Script:pipeProxy = $pipeFactory.CreateChannel()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
The variable '$Script:pipeProxy' cannot be retrieved because it has not been set.
At C:\Program Files\WindowsPowerShell\Modules\ZLocation\0.1.0\ZLocation.Storage.psm1:33 char:5
+ $Script:pipeProxy
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Script:pipeProxy:String) [], RuntimeException
+ FullyQualifiedErrorId : VariableIsUndefined
Add-Type : (0) : 'c:\Users\tyler.thrailkill\AppData\Local\Temp\CSCC370CD6B1B00420DADFD74FE529EFB28.TMP' is not a valid Win32 resource file
(1) : using System;
At C:\Program Files\WindowsPowerShell\Modules\ZLocation\0.1.0\ZLocation.Storage.psm1:68 char:42
+ ... e-Command { Add-Type -ReferencedAssemblies System.ServiceModel -TypeD ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (error CS1583: '...2 resource file:CompilerError) [Add-Type], Exception
+ FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand
WARNING: ZLocation Pipe become broken :( ZLocation is now self-disabled.
You need to restart all PowerShell instances to re-enable ZLocation.
Please continue your work and do it, when convinient.
You can report the problem on https://github.com/vors/ZLocation/issues
WARNING: Cannot find matching location
PS>
z ..\gototab-chrome-extension
At C:\dev\ZLocation\ZLocation\ZLocation.Search.psm1:55 char:12
+ return ($leaf -match $query[$n-1])
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException
parsing "..\gototab-chrome-extension" - Unrecognized escape sequence \g.
At C:\dev\ZLocation\ZLocation\ZLocation.Search.psm1:55 char:12
+ return ($leaf -match $query[$n-1])
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException
parsing "..\gototab-chrome-extension" - Unrecognized escape sequence \g.
At C:\dev\ZLocation\ZLocation\ZLocation.Search.psm1:55 char:12
+ return ($leaf -match $query[$n-1])
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException
parsing "..\gototab-chrome-extension" - Unrecognized escape sequence \g.
At C:\dev\ZLocation\ZLocation\ZLocation.Search.psm1:55 char:12
+ return ($leaf -match $query[$n-1])
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException
parsing "..\gototab-chrome-extension" - Unrecognized escape sequence \g.
At C:\dev\ZLocation\ZLocation\ZLocation.Search.psm1:55 char:12
+ return ($leaf -match $query[$n-1])
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException
parsing "..\gototab-chrome-extension" - Unrecognized escape sequence \g.
At C:\dev\ZLocation\ZLocation\ZLocation.Search.psm1:55 char:12
+ return ($leaf -match $query[$n-1])
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException
parsing "..\gototab-chrome-extension" - Unrecognized escape sequence \g.
At C:\dev\ZLocation\ZLocation\ZLocation.Search.psm1:55 char:12
+ return ($leaf -match $query[$n-1])
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException
parsing "..\gototab-chrome-extension" - Unrecognized escape sequence \g.
At C:\dev\ZLocation\ZLocation\ZLocation.Search.psm1:55 char:12
+ return ($leaf -match $query[$n-1])
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException
parsing "..\gototab-chrome-extension" - Unrecognized escape sequence \g.
At C:\dev\ZLocation\ZLocation\ZLocation.Search.psm1:55 char:12
+ return ($leaf -match $query[$n-1])
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException
parsing "..\gototab-chrome-extension" - Unrecognized escape sequence \g.
At C:\dev\ZLocation\ZLocation\ZLocation.Search.psm1:55 char:12
+ return ($leaf -match $query[$n-1])
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException
parsing "..\gototab-chrome-extension" - Unrecognized escape sequence \g.
At C:\dev\ZLocation\ZLocation\ZLocation.Search.psm1:55 char:12
+ return ($leaf -match $query[$n-1])
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException
If unexciting path is a first choice.
Also it make sense to review all old bugs of Jump-Location and try repro them for ZLocation.
I don't have the windows machine at a moment and cannot do publishing to the gallery from mac.
PowerShell/PowerShellGet#25
Exception calling "Add" with "2" argument(s): "Item has already been added. Key in dictionary: '' Key being added: ''"
At ...\WindowsPowerShell\Modules\ZLocation\1.0.0\ZLocation.Storage.psm1:12 char:9
+ $hash.add($item.path, $item.weight)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentException
ZLocation worked great until this happened. What can I do?
Found while investigating #84 and #85, but probably not their cause: $path
on Update-ZLocation
isn't mandatory or provided with a default, so it's possible to run just Update-ZLocation
. This makes it to the database and breaks ZLocation. The same is true of Add-ZWeight
etc.
PS H:\> z
Weight Path
------ ----
1 H:\
PS H:\> Update-ZLocation
PS H:\> z
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
At C:\Program Files\WindowsPowerShell\Modules\ZLocation\1.2.0\ZLocation.Service.psm1:76 char:9
+ Write-Error $error[0]
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentOutOfRangeException
+ FullyQualifiedErrorId : System.ArgumentOutOfRangeException
When I install and then import the module, I get an error message.
PSVersion: 5.0.11082.1000
Windows 10 Pro x64
PS C:> ipmo ZLocation
WARNING: ZLocation Pipe become broken :( ZLocation is now self-disabled.
You need to restart all PowerShell instances to re-enable ZLocation.
Please continue your work and do it, when convinient.
You can report the problem on https://github.com/vors/ZLocation/issues.
The posh-git module injects its own prompt function that provides various features including a Git status display in the prompt. As soon as you Import-Module ZLocation
, it breaks the posh-git prompt function i.e. the prompt degenerates to PS>
:
The reason it breaks is that the Register-PromptHook
function doesn't just append Update-ZLocation $pwd
to the front of the prompt function. It creates a new scriptblock in the scope of the ZLocation module.
ZLocation/ZLocation/ZLocation.psm1
Lines 45 to 59 in 2ccc541
This breaks posh-git because it created its prompt scriptblock within the posh-git module e.g.:
C:\Users\Keith
09-11 20:05:57 3> (Get-Command Prompt).Module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0.0 posh-git {Add-PoshGitToProfile, Add-SshKey, Expand-GitCommand, Form...
C:\Users\Keith
09-11 20:06:00 4> ipmo ZLocation
PS>(Get-Command Prompt).Module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 0.0 __DynamicModule_3cd9b6f8-0961-47...
The results in errors that prevent the posh-git prompt function, recreated in a new scriptblock, from being able to access private, module-scoped functions:
PS>$error
The term 'EscapeAnsiString' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
EscapeAnsiString : The term 'EscapeAnsiString' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:102 char:37
+ $global:PoshGitLastPrompt = EscapeAnsiString $prompt
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (EscapeAnsiString:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
One possible workaround it to special case posh-git
. Yeah I don't think it is a great solution but it does work. :-) This is done by a simple check for a posh-git defined prompt function in the Register-PromptHook
function and then injecting a scriptblock that invokes Update-ZLocation $pwd
:
function Register-PromptHook
{
param()
# If posh-git is supplying the prompt function, inject update command via the posh-git VcsPromptStatuses hook
$prompt = Get-Command prompt -CommandType Function -ErrorAction SilentlyContinue
if ($prompt -and $prompt.module -and $prompt.module.name -eq 'posh-git') {
$global:VcsPromptStatuses += { [void](Update-ZLocation $pwd) }
return
}
…
I'm definitely open to other ideas that are more widely applicable. Ideally the PowerShell engine would expose an event that fires whenever the FileSystem provider changes location.
BTW the above solution is dependent on module import order. It will work if ZLocation is imported after posh-git. If ZLocation is imported before posh-git, then posh-git punt on modifying the prompt function because it "appears" the user has their own customized prompt.
cc @dahlbyk
Having been using rupa's famous z.sh under linux for years, thanks for ZLocation, because I can use the same z on Windows now.
It is very convenience if ZLocation could support two more z.sh's feature:
very handy to see what in my history.
z -l <key1> [key2, key3, ...]
:People using z sometimes got confused what path will be matched with they keywords.
Then they have a z -l
command to test they keywords before jumping if they are not so sure.
z -l <key1> [key2, key3, ...]
is a very high frequency command in my everyday workflow.
Is it possible to add these two features in ZLocation ?? If so, working with ZLocation will be much more productive.
🐛 Somehow, the second weighted path is picked.
> z -l posh
Weight Path
------ ----
107 C:\Users\Zhao\Documents\WindowsPowerShell\Modules\oh-my-posh
65 C:\Users\Zhao\Documents\WindowsPowerShell\Modules\posh-git
12 C:\Users\Zhao\Documents\WindowsPowerShell\Modules\git-status-cache-posh-client
6 C:\ProgramData\chocolatey\lib\git-status-cache-posh-client
6 C:\ProgramData\chocolatey\lib\git-status-cache-posh-client\tools\git-status-cache-posh-client-1.0.0
> z posh ; pwd
Path
----
C:\Users\Zhao\Documents\WindowsPowerShell\Modules\posh-git
👍 However, sometimes the first weighted path is chosen as expected.
> z -l app
Weight Path
------ ----
16 C:\tools\scoop\apps
12 C:\Users\Zhao\AppData
7 C:\Users\Zhao\AppData\Local\atom\app-1.9.9
5 C:\Users\Zhao\Dropbox\Apps
z app ; pwd
Path
----
C:\tools\scoop\apps
💡 Any idea?
I try to cd
ed to some directories, then z
to those directories and failed. Then I tried Get-zLocation
and it gives me nothing.
zLocation version: 1.1
PowerShell version: 6.1.2
Windows version: Windows 10 Pro 1809, 17763.253
It seems that when starting Powershell as user A and importing the ZLocation module it creates the service instance, and then when starting Powershell again with different credentials, i.e. as user B, it uses the service from user A, resulting in locations used by user B being added to those for user A, which is pretty annoying.
Problem: navigating to new folders (with cd) does not update the z db.
I run powershell 5.1 but my computer is connected to an AD.. i'm wondering if the $HOME variable changing when disconnected from network might cause trouble.
We should either declare
# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '5.0'
or avoid using ::new()
syntax
https://github.com/vors/ZLocation/pull/62/files#r219012334
Both options seems pretty easy to implement, I have a sligh preference toward using the 3.0+ support, but as @cspotcode pointed out the tool is only for interactive use, so for most people it's probably fine to have 5.0+ only.
Hi, first thank you for creating this plugin! I enjoy using z.sh on Linux and I was super excited when seeing this project!
Unfortunately I could not get this working. Everytime I execute z
. I get the following error:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
At C:\Program Files (x86)\WindowsPowerShell\Modules\ZLocation\1.2.0\ZLocation.Service.psm1:76 char:9
+ Write-Error $error[0]
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentOutOfRangeException
+ FullyQualifiedErrorId : System.ArgumentOutOfRangeException
My setup:
PS> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 1 17763 592
Terminal: Cmder version 180626
Windows version: 10.0.17763 Build 17763
On a fresh install, deleting ~/z-location.db and not calling Update-Location from prompt, doing it manually results in:
Update-ZLocation $pwd
call takes ~3-4sUpdate-ZLocation $pwd
call throws:Exception calling "Insert" with "1" argument(s): "Cannot insert duplicate key in unique index '_id'. The duplicate value is '"C:\\Users\\vladv"'."
At C:\Users\vladv\Documents\PowerShell\Modules\ZLocation\1.2.0\ZLocation.LiteDB.psm1:19 char:5
+ $collection.Insert((ToDocument $item)) | out-null
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : LiteException
pwsh 7.0-preview2, Windows 10
The Pester setup for mocking Get-ZLocationDatabaseFilePath
and Get-ZLocationLegacyBackupFilePath
doesn't work: the mocked functions are never actually called and tests run using my actual database.
The easiest way to confirm this is lock the production database and run the tests- if they were using the testing database, this wouldn't be an issue, but instead database operations fail. Other tests such as checking mocks are actually called suggest the same thing.
Can we make it work on CoreCLR / unix?
Everything works, except I get this error all the time
Split-Path : Cannot process argument because the value of argument "path" is not valid. Change the value of the "path" argument and run the operation again.
At /usr/local/share/powershell/Modules/ZLocation/1.2.0/ZLocation.Search.psm1:99 char:13
+ $leaf = Split-Path -Leaf $path
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Split-Path], PSArgumentException
+ FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.SplitPathCommand
Hi, I am new to PowerShell, Thank you for such an amazing Module!
I have been using it for quite some time now, and I thought it could be good for my workflow if I could auto-complete directories in other commands too.
If tab-completion related commands were exported/exposed, then it would greatly improve my workflow and possibly for other users as well.
Example
code <tab>
would auto-complete the most used one and I can directly open that in my code editor
explorer mobile<tab>
would auto-complete the most used directory with mobile in it and I can open that in explorer.
This would require me to Register-ArgumentCompleter
for code
and explorer
commands. But I can't do that without the required commands from ZLocation.
The required commands are Find-Matches
and Get-ZLocation
If there is a way for me to use those commands without you exporting/exposing them, please tell me. Currently I am trying to do it this way Import-Module <path-to-modules>/ZLocation/<version>/<required-but-private-module-name>.psm1
.
Exception calling "EnsureIndex" with "1" argument(s): "The process cannot access the file '/Users/svorobev/z-location.db' because it is being used by another process."
At /Users/svorobev/.local/share/powershell/Modules/ZLocation/1.0.0/ZLocation.Service.psm1:78 char:5
+ $collection.EnsureIndex('path')
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : IOException
We should backoff / retry when we have shared resource problem (at least on mac)
If I have been to directory A but have not been to a directory B which is in A and my current path is A, calling "z B" does not work.
I have the PowerLine and oh-my-posh modules installed that give me a nice segmented command prompt with git info.
As soon as I invoke z
to navigate to a folder, it works, but afterwards, my prompt reverts to PS>
:
F: > sample > folder > master ≣ > z otherfolder
PS>
This is my fault. I'm checking $IsMacOS
even though that variable is not set on WindowsPowerShell. Should be an easy fix.
https://github.com/vors/ZLocation/blob/master/ZLocation/ZLocation.Service.psm1#L54
My db contains this:
285 C:\work\dots
310 C:\work\dots2
...
But when I go to "dots" it selects "dots2" because it has higher weight.
I expect that if I type in a folder name that matches exactly, it would select that one rather than something else that has a higher weight, but is a partial match.
Took me forever to figure this out, but it seems that on my system, "Invoke-ZLocation" if passed multiple parameters forced them to flatten before calling "Set-ZLocation". Changing line 288 of ZLocation.psm1 from
Set-ZLocation $match
to
Set-ZLocation -match $match
Fixed the issue for me.
I like to alias Set-ZLocation with j instead of z because then it is on the home row and is easier to press as apposed to z which requires a pinkie contortion to achieve. However aliasing with j to Set-ZLocation does not work as the tab completion does not execute properly.
Publish-Module - that should say it all :)
Creating this to track an issue I've noticed. If another module loads a conflicting version of LiteDB, we might hit problems. I'm not sure if there is a proper solution to this. I've been playing around with creating a new AssemblyLoadContext
to load LiteDB.dll. This is apparently dotnet core's solution for isolating assemblies and loading conflicting versions in the same process. So far it has been working for me.
class MyAssemblyLoadContext : Runtime.Loader.AssemblyLoadContext {
[Reflection.Assembly] Load([Reflection.AssemblyName]$assemblyName) {
return $null
}
}
$myAssemblyLoadContext = [MyAssemblyLoadContext]::new()
$assembly = $myAssemblyLoadContext.LoadFromAssemblyPath([IO.Path]::Combine($PSScriptRoot, "LiteDB\LiteDB.dll"))
Function GetLiteDBType($name) {
ForEach($t in $assembly.ExportedTypes) {
if($t.name -eq $name) {
return $t
}
}
}
$TAType = [psobject].Assembly.GetType('System.Management.Automation.TypeAccelerators')
$TAType::Add('accelerators', $TAType)
[accelerators]::Add('LDBQuery', (GetLiteDBType 'Query'))
[accelerators]::Add('LDBBsonValue', (GetLiteDBType 'BsonValue'))
[accelerators]::Add('LDBBsonDocument', (GetLiteDBType 'BsonDocument'))
[accelerators]::Add('LDBBsonId', (GetLiteDBType 'BsonIdAttribute'))
[accelerators]::Add('LDBBsonMapper', (GetLiteDBType 'BsonMapper'))
[accelerators]::Add('LDBLiteDatabase', (GetLiteDBType 'LiteDatabase'))
[accelerators]::Add('LDBLiteCollection', (GetLiteDBType 'LiteCollection`1'))
Type accelerators are, unfortunately, not scoped to a module, so we'd either have to give the type accelerators a more unique prefix or avoid them entirely. I think [$referenceToType]
syntax works.
Hello,
now that zlocation supports powershell core I tried it macOS; works fine so far but I noticed a minor nuisance:
ZLocation puts its database to $HOME/zlocation.db
, ie, a visible file. The file appears in ls
or in Finder (=macos explorer) windows.
On Unix, data files of this kind are normally created as hidden files, with a leading dot: $HOME/.zlocation.db
.
Would it be possible to move the database to this place on Unix, so that it doesn't clutter my $HOME
directory?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.