When I use tab completion in Powershell to complete a relative path Powershell converts it into an absolute one. While the absolute paths work it's getting kind of annoying (making my commands really long and making me reshift my focus when I autocomplete). Is there any way to change it to keep the relative paths when tab completing?
|
feedback
|
|
Customizing PowerShell Tab Expansion You can customize tab expansion in PowerShell by replacing the "TabExpansion" function. You can get the current contents of the function with {{Get-Content function:TabExpansion}}. This function should return all the results that should be presented to the user. There are some gotchas to deal with. Implementing Relative Paths The default TabExpansion function does not do the path expansion, it lets the PowerShell engine do path expansion, which is the absolute last fall back. So you will need to add path handling to what comes with PowerShell. A Better Option I am a contributor to the PowerTab project, which is a rich implementation of tab expansion in PowerShell. It offers relative path support, as well as a ton of other stuff (WMI class names, .NET type names, shares, method signatures, etc.). The work will already be done for you. Trying Yourself If you want to try adding this one feature to the default code, you can check out the end of this file, starting with the comment "## Filesystem Completion": http://powertab.codeplex.com/SourceControl/changeset/view/040492b7d2d1#TabExpansionCore.ps1 There is quite a bit of PowerTab specific code in that block, but I can help you out if you want to try. | |||
|
feedback
|
