Giter VIP home page Giter VIP logo

cd-extras's People

Contributors

csr-nick avatar ja-nick avatar jamesmcgill avatar jetersen avatar nickcox avatar qbikez 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

cd-extras's Issues

cd to invalid subfolder moved to root of drive

After installing this module (v0.8.1), cd to a non-existant dir moves to the root of the current drive, with no warning or error

PS C:\Users\username\Documents> cd not_a_dir
PS C:\>

I would expect it to stay in the current directory and report an error (as vanilla powershell does)

PS C:\Users\username\Documents> cd not_a_dir
cd : Cannot find path 'C:\Users\username\Documents\not_a_dir' because it does not exist.
At line:1 char:1
+ cd not_a_dir
+ ~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\username\Documents\not_a_dir:String) [Set-Location], Ite
   mNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
PS C:\Users\username\Documents>

Step-Up (..) errors cd'ing to drive root on Windows

Latest version of cd-extras

┌( thorsten@rednails) ( F:/cygwin)
└( powershell)❯ ..
Set-Location: C:\Users\thorsten\Documents\PowerShell\Modules\cd-extras\2.9.2\public\Step-Up.ps1:50
Line |
  50 |      Set-LocationEx -LiteralPath $target -PassThru:$PassThru
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot find path 'F' because it does not exist.

No indication that transpose location failed

Shouldn't there be an error (or at least information) if no transformation could be done? Obviously a user issuing the command expects something to happen:

[thorsten] > pwd

Path
----
F:\cygwin\home\thorsten


[thorsten] > cd thorsten guest
[thorsten] > pwd

Path
----
F:\cygwin\home\thorsten

Warning when `#Requires` used

When cd-extras is used in connection with #Requires -Module cd-extras a warning issued:

WARNING: The names of some imported commands from the module 'cd-extras' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.

The warning is described in the Readme but since we are not manually importing cd-extras, the workaround is not applicable.

[Suggestion] Mention PSReadLine as a dependency.

For some reason PSReadLine wasn't installed on my machine (win10) but I saw it's required for a bit of the functionality. I quickly fixed that by installing it.

Maybe you could mention in the readme somewhere that it's required and have a one liner to install the module.

Set-Alias : The AllScope option cannot be removed from the alias '~'.

When doing a default installation from the Gallery, I received the previous error after importing the module from my $PROFILE.
After commenting line 13 of the Aliases.ps1 file, the error goes away, but ~ doesn't work as expected from the module.

Changing the line from:

Set-Alias '~' Undo-Location

to:
Set-Alias -Name '~' -Value Undo-Location -Option AllScope

Seems to solve the problem

$cde redefined by import module

Hi, looks like something broken with $cde config

Install-Module -Name cd-extras -AllowPrerelease

In $profile:

$cde = @{
    AUTO_CD  = $true
    CD_PATH  = 'q:\\code\\Telgorithm', 'q:\\code\\vchirikov'
    NOARG_CD = 'q:\\code'
}
Import-Module cd-extras

output:

$cde

AUTO_CD               : True
CDABLE_VARS           : False
CD_PATH               : {}
NOARG_CD              : ~
RECENT_DIRS_FILE      :
RECENT_DIRS_EXCLUDE   : {}
RecentDirsFallThrough : True
MaxRecentDirs         : 120
MaxRecentCompletions  : 60
MaxCompletions        : 0
MaxMenuLength         : 36
WordDelimiters        : {., _, -}
DirCompletions        : {Set-Location, Set-LocationEx, Push-Location}
PathCompletions       : {Get-ChildItem, Get-Item, Invoke-Item, Expand-Path}
FileCompletions       : {}
ColorCompletion       : False
IndexedCompletion     : True
ToolTip               :  param ($item, $isTruncated)
                            "{0} $(if ($isTruncated) {'{1}'})" -f
                            $item, "$([char]27)[3m(+additional results not displayed)$([char]27)[0m"

As you can see NOARG_CD redefined to the wrong value (and other values too) and doesn't work :(

Prep 3.0 Release

  • Break up docs
  • Implement pluggable freceny providers
  • Document pluggable frecency providers
  • Check for regressions in startup perf
  • Test coverage
  • Fix any outstanding bugs
  • Address annoying Pester legacy syntax warning

No error changing to unquoted directory with space in name

This is possibly related to #3:

[thorsten] > cd directory with space
[thorsten] > pwd

Path
----
F:\cygwin\home\thorsten

Standard behaviour:

[thorsten] > cd directory with space
Set-Location : A positional parameter cannot be found that accepts argument 'with'.
At line:1 char:1
+ cd directory with space
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidArgument: (:) [Set-Location], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetLocationCommand```

Can't change into directory with space in name

[~] pwsh> cd '.\directory with'

cmdlet Transpose-Location at command pipeline position 1
Supply values for the following parameters:
With:

It looks llike the problem is confined to directory names consisting of two words. The heuristic mentioned in #4 seems not to work properly.

Can't set option NOARG_CD

> Set-CdExtrasOption -Option NOARG_CD -Value '~'
Set-CdExtrasOption : Cannot validate argument on parameter 'Option'. The argument "NOARG_CD" does not belong to the set "AUTO_CD;CD_PATH" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again.
At line:1 char:28
+ Set-CdExtrasOption -Option NOARG_CD -Value '~'
+                            ~~~~~~~~
+ CategoryInfo          : InvalidData: (:) [Set-CdExtrasOption], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Set-CdExtrasOption

`cd` without argument has no function

Traditional Unix shells change to the user's home directory when using cd without argument. In its current implementation cd just doesn't do anything.

I propose to add functionality:

  • change to $HOME or
  • show the directory stack (like Pscx does)
  • (something else which gives the user benefit)

Add a set of regression tests

As these small scripts become more involved, we're going to need a set of tests to ensure that nothing gets broken in the course of fixing or improving something else.

Tab completion for directories gives full path and no quotes

Trying tab completion for a directory gives full path and no quotes. While the former is debatable, the latter is clearly a bug:

cd-extras:

[thorsten] > cd dir<TAB>
[thorsten] > cd F:\cygwin\home\thorsten\directory with space[ENTER]
[thorsten] > pwd

Path
----
F:\cygwin\home\thorsten

Standard behaviour:

[thorsten] > cd dir<TAB>
[thorsten] > cd '.\directory with space'[ENTER]
[directory with space] > pwd

Path
----
F:\cygwin\home\thorsten\directory with space

cd-extras is not powershell v5 compatible

PowerShellVersion = '5.0'

As far as I know the ? operator is not supported, this is only supported in powershell 7.

This:

$invocation = $isUnderTest ? $CommandName : $MyInvocation.Line

Has to be written like this

$invocation = if ($isUnderTest) { $CommandName } else { $MyInvocation.Line }
% : At C:\Users\joseph\Documents\WindowsPowerShell\Modules\cd-extras\2.9.1\private\CommandNotFound.ps1:10 char:32
+     $invocation = $isUnderTest ? $CommandName : $MyInvocation.Line
+                                ~
Unexpected token '?' in expression or statement.
At C:\Users\joseph\Documents\WindowsPowerShell\Modules\cd-extras\2.9.1\cd-extras.psm1:3 char:45
+ Get-ChildItem $PSScriptRoot/private/*.ps1 | % { . $_.FullName }
+                                             ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ParserError: (:) [ForEach-Object], ParseException
    + FullyQualifiedErrorId : UnexpectedToken,Microsoft.PowerShell.Commands.ForEachObjectCommand

Import-Module : The module to process 'cd-extras.psm1', listed in field 'ModuleToProcess/RootModule' of module manifest
'C:\Users\joseph\Documents\WindowsPowerShell\Modules\cd-extras\2.9.1\cd-extras.psd1' was not processed because no valid module was found in any module directory.
At C:\Users\joseph\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:30 char:11
+           Import-Module $moduleName
+           ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (cd-extras:String) [Import-Module], PSInvalidOperationException
    + FullyQualifiedErrorId : Modules_ModuleFileNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

The property 'CD_PATH' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\joseph\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:328 char:1
+ $cde.CD_PATH = @($developmentWorkspace)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

cd-extras breaks tab expansion of UNC paths

Without cd-extras being loaded, in PowerShell 7.1.3, if I enter

gci \\pnjnas\p\photos\class

and hit the Tab key I get:

image

If cd-extras (version 2.2.0) is loaded, hitting the Tab key in the same context does nothing, and a (caught) exception is raised:

PS C:\Users\<REDACTED>> $error[0] | select *

PSMessageDetails      :
Exception             : System.Management.Automation.MethodInvocationException: Exception calling "CompleteInput" with
                        "3" argument(s): "Object reference not set to an instance of an object."
                         ---> System.NullReferenceException: Object reference not set to an instance of an object.
                           at
                        System.Management.Automation.CompletionCompleters.InvokeScriptArgumentCompleter(ScriptBlock
                        scriptBlock, Object[] argumentsToCompleter, List`1 result)
                           at
                        System.Management.Automation.CompletionCompleters.InvokeScriptArgumentCompleter(ScriptBlock
                        scriptBlock, String commandName, String parameterName, String wordToComplete, CommandAst
                        commandAst, CompletionContext context, List`1 resultList)
                           at System.Management.Automation.CompletionCompleters.NativeCommandArgumentCompletion(String
                        commandName, CompiledCommandParameter parameter, List`1 result, CommandAst commandAst,
                        CompletionContext context, Dictionary`2 boundArguments)
                           at System.Management.Automation.CompletionCompleters.ProcessParameter(String commandName,
                        CommandAst commandAst, CompletionContext context, List`1 result,
                        MergedCompiledCommandParameter parameter, Dictionary`2 boundArguments)
                           at System.Management.Automation.CompletionCompleters.GetArgumentCompletionResultsWithSuccess
                        fulPseudoBinding(CompletionContext context, ArgumentLocation argLocation, CommandAst
                        commandAst)
                           at
                        System.Management.Automation.CompletionCompleters.CompleteCommandArgument(CompletionContext
                        context)
                           at System.Management.Automation.CompletionAnalysis.GetResultForIdentifier(CompletionContext
                        completionContext, Int32& replacementIndex, Int32& replacementLength, Boolean isQuotedString)
                           at System.Management.Automation.CompletionAnalysis.GetResultHelper(CompletionContext
                        completionContext, Int32& replacementIndex, Int32& replacementLength, Boolean isQuotedString)
                           at System.Management.Automation.CompletionAnalysis.GetResults(PowerShell powerShell, Int32&
                        replacementIndex, Int32& replacementLength)
                           at System.Management.Automation.CommandCompletion.CompleteInputImpl(Ast ast, Token[]
                        tokens, IScriptPosition positionOfCursor, Hashtable options)
                           at System.Management.Automation.CommandCompletion.CompleteInput(String input, Int32
                        cursorIndex, Hashtable options)
                           at CallSite.Target(Closure , CallSite , Type , String , Int32 , Hashtable )
                           --- End of inner exception stack trace ---
                           at
                        System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocationException(Exception
                        exception, Type typeToThrow, String methodName, Int32 numArgs, MemberInfo memberInfo)
                           at CallSite.Target(Closure , CallSite , Type , String , Int32 , Hashtable )
                           at System.Management.Automation.Interpreter.DynamicInstruction`5.Run(InterpretedFrame frame)
                           at
                        System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
                        frame)
TargetObject          :
CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : NullReferenceException
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock><End>, <No file>: line 38
                        at PSConsoleHostReadLine,
                        C:\Users\<REDACTED>\OneDrive\Documents\PowerShell\Modules\PSReadLine\2.2.0\PSReadLine.psm1: line 4
PipelineIterationInfo : {}

PathCompletion results should be bounded

Path completion can be slow when returning thousands of results. The number of completion results should be limited (50-60, perhaps) and, ideally, configurable.

Prep for 1.0

  • Enable clearing of stacks
  • Provide FileCompletions option similar to DirCompletions but for files and PathCompletions for commands that can work on either directories or files
  • Consider an option to recover discarded redo stacks maybe later
  • Consider running tests through a profiler

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.