nickcox / cd-extras Goto Github PK
View Code? Open in Web Editor NEWsuperpowers for the Powershell `cd` command⚡
License: MIT License
superpowers for the Powershell `cd` command⚡
License: MIT License
The undo and redo stacks should integrate properly with pwsh 6.2's new cd -
and cd +
capability.
My guess is that the Windows Terminal consumes the tab character and does not get propagated to cd extra
include the ending \
of directories in the completion to simulate the default behavior of PowerShell.
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>
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.
It is convenient to have history location navigation cmdlet, in many cases, we don't have to distinguish the redo or undo.
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
The auto-completion doesn't escape everything correctly.
e.g. cd 'C:\Temp\logs1\temp\ae93eef3-bc54-4ff7-a911-d311077791b7\2018-11-13T23.55.26 - [notifications]\'
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.
Hi could we have an option to disable the beep?
cd-extras/cd-extras/private/CompletePaths.ps1
Line 120 in e111a9e
There is no "Project Site" link to this repository on PowerShell Gallery making the project's place hard to find.
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.
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:
cd-extras/cd-extras/public/Aliases.ps1
Line 13 in e111a9e
to:
Set-Alias -Name '~' -Value Undo-Location -Option AllScope
Seems to solve the problem
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 :(
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```
cd HKLM:\Software
followed by
..
does not change the current location to HKLM:
[~] 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.
[~] pwsh> pwd
Path
----
/home/thorsten
[~] pwsh> ..
[home] pwsh> pwd
Path
----
/home
[home] pwsh> ..
[home] pwsh> pwd
Path
----
/home
> 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
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:
$HOME
orPscx
does)Completions for the FileSystem provider could allow optional colourisation via DirColors.
Would be nice to allow additional commands (e.g. ls
) to trigger enhanced tab completion.
Possible to have colored items? Is it already supported or can it be added?
https://github.com/joonro/Get-ChildItemColor
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.
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/cd-extras/cd-extras.psd1
Line 9 in 2a8ca1d
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
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:
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 : {}
Path completion can be slow when returning thousands of results. The number of completion results should be limited (50-60, perhaps) and, ideally, configurable.
FileCompletions
option similar to DirCompletions
but for files and PathCompletions
for commands that can work on either directories or filesA 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.