question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

visualize/tab-completion with forward slash as separator on Windows

See original GitHub issue

Description of the new feature/enhancement

I’m beginning user in PSREadLine and would like to use more a Unix-like behavior inside PowerShell on Windows. Two things come to my mind to extends PSReadLine:

  1. Visualize slash as separator. For instance, I would like to configure PSReadLine to show the local directory indication as
    PS /Users/alan> instead of PS C:\Users\alan>

  2. Enable tab-completion using forward slash. Today when using tab-completion the forward slash is converted to slash. For instance, ls /Users/ followed by tab is automatic converted to C:\Users

Thanks in advance for any feedback.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
3N4Ncommented, Jan 30, 2023

@jd1378 @alanlivio I looked into the code and there is no way, at least no simple way, to use unix-directory-separator in PSReadLine. There is a place that appends a directory separator, and that’s patchable, but that only changes the last directory separator, not the preceding ones. The preceding separators are decided here:

https://github.com/PowerShell/PSReadLine/blob/9957183ff2eb128a8f9df9e077c22acf21b72fdd/PSReadLine/Completion.cs#L291

CompleteInput is a PowerShell builtin method, unalterable. And the value it returns is of type CommandCompletion, which is readonly, so you can’t even manually edit it after its creation. In other words, there is no simple way to patch PSReadLine so it uses unix directory separator in Windows.

@daxian-dbw could you care to verify my observations?

1reaction
daxian-dbwcommented, Feb 6, 2023

Sorry for the late response. @3N4N was right, the completion results for path are returned from the tab completion APIs in PowerShell engine, not generated by PSReadLine. So, the ask should better post in the PowerShell repo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Windows forward slash and backslash characters as ...
Answer. The UNC syntax is sometimes written with forward slashes. In Windows the forward slashes and back slashes are equivalent, ...
Read more >
When did Windows start accepting forward slash as a path ...
Using Windows 7 and Windows 10 an both accepting / as path separator using File Explorer (e.g. c:/ will automatically converted to c:\)....
Read more >
Path.DirectorySeparatorChar Field (System.IO)
If you prefer to hard-code the directory separator character, you should use the forward slash ( / ) character. It is the only...
Read more >
Why does the cmd.exe shell on Windows fail with paths ...
One can debate whether Windows CMD is "supposed" to support forward slashes. But that last result is a bug! Even if there is...
Read more >
Why does Windows use backslashes for paths and Unix ...
The underlying Windows API can accept either the backslash or slash to separate directory and file components of a path, but the Microsoft...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found