Code Monkey home page Code Monkey logo

zlocation's People

Contributors

adamlopresto avatar citelao avatar cspotcode avatar deltoss avatar dlwyatt avatar eedrah avatar gitter-badger avatar karinakozarova avatar lyahdav avatar nohwnd avatar rkeithhill avatar sleepybag avatar stinos avatar theaquamarine avatar vors avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zlocation's Issues

Path info in default z output is clipped

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

Jump to number fails

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

Z Should prioritize the beginning of a foldername

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)

Intellisense isn't working

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

all known locations cleared on update

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.

Warning message is misspelled and grammatically incorrect.

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.

1.0 release has several errors

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 ..

Set-ZLocation .. returns 'Warning: Cannot find matching location"

Exception calling "Add" with "2" arguments

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?

Unable to cast object of type 'LiteDB.ObjectId' to type 'System.String'

after a day or so of using ZLocation, I start to get this error:

C:\Users\whatever\AppData\Roaming\Local\tempz 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)

Doesn't work with Cmder

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

Trying to navigate to directory, ZLocation disables itself

λ ~ 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>

relative path produce bunch of errors

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

"Exceptiong calling 'Add' with '2' arguments"

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?

Update-ZLocation $path should be mandatory

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

Fails on first import

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.

Register-PromptHook breaks posh-git prompt

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>:

image

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.

function Register-PromptHook
{
param()
$oldPrompt = Get-Content function:\prompt
if( $oldPrompt -notlike '*Update-ZLocation*' )
{
$newPrompt = @'
Update-ZLocation $pwd
'@
$newPrompt += $oldPrompt
Set-Content -Force -Path function:\prompt -Value ([ScriptBlock]::Create($newPrompt))
}
}

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

[wish-list] list histories when running z without args and test match when using 'z -l'

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:

  1. list path history and priority when calling z without parameters:

z-1

very handy to see what in my history.

  1. test match with z -l <key1> [key2, key3, ...]:

z-4

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.

Graceful migration to LiteDB for existing users

@vors I saw you mention this on #47.

Is this what you have in mind?
On startup, if LiteDB database file does not exist and legacy zlocation text file does exist, copy all entries from text file into database file.

I think that should do the trick.

:bug: the second weighted path is picked

🐛 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?

ZLocation fails to remember any directory.

I try to cded 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

Different users all use the same ZLocation service

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.

Z-location is not recording folders

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.

Index was out of range on fresh install

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

Update-ZLocation takes a long time; errors after second call

On a fresh install, deleting ~/z-location.db and not calling Update-Location from prompt, doing it manually results in:

  1. first Update-ZLocation $pwd call takes ~3-4s
  2. second Update-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

Database mocking not working

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.

Got into a corrupted db state, every change of location print error

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

[Feature Request] Expose tab-completion related commands/functions

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.

Starting 2 pwsh sessions at the same time on macos leads to an error

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)

Invoking `z` drops my custom prompt

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>

Invoke-Zlocation doesn't call Set-ZLocation correctely

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.

Alias for Set-ZLocation does not provide tab completion

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.

Avoid assembly conflicts with other versions of LiteDB

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.

Hide z-location.db on Unix

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.