-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows / PowerShell Functionality #32
Comments
Windows 10 x64 user here: The problem also appears at the CMD prompt. It's not limited to Powershell. |
@michaeltlombardi Thank you so much for the really well-written issue and screen captures. It is very much appreciated. Unfortunately, I do not have a windows machine so it is a little hard for me to debug and I have very little knowledge of how Powershell / Windows works, but I would really like for For what it's worth Out of curiosity, does |
I imagine the prompt mangling could be an issue with the difference between line returns on windows vs unix maybe when the |
@maaslalani it does! fzf --version
fzf
$a = fzf
$a
I also tested whether (fzf) -replace '\.', '!'
(fzf) | ForEach-Object {
$Parts = $_ -split '\.'
[PSCustomObject]@{
Name = $Parts[0]
Extension = $Parts[1]
}
} | Format-List
Taking a peek into |
Looking around, I'm not seeing too many places where they're doing Windows-specific handling.
|
Wanted to let you know that this isn't isolated to gum. I am experiencing an identical issue with a program I wrote using the bubbletea library. https://github.com/hay-kot/gofind Notable Things...
Happy to help troubleshoot on windows as well. |
Just to add to these. When using Reading input is the key to the above. If I do:
However, if I use
I tested with a different program that keeps on running instead of running Get-Content, I was able to use I tested this on Windows PowerShell v5.1 and PowerShell v7 on Windows 10. I may try testing |
I can't say I know the first thing about this topic and I apologize if this is just noise, but I remember that Taskfile uses https://pkg.go.dev/mvdan.cc/sh/v3 under the hood to smooth out variances between OSes and shells. Of course it introduces at least another dependency and I'm not sure if this aligns with the intentions of the authors... |
This was way harder than I would have thought to figure out. Had to bang my head against how to get the console stream input on Windows. Couldn't just use stdin since it can sometimes be a pipe (e.g. when using |
I pulled down @immersivegamer fork and am still having the same issue with Gum described in the original issue. It looks like your fix implements what is more or less suggested here I've tried modifying the code to explicitly use the handle and flag as specified in the python example in the issue, but still get the same results no matter what I've tried. Will continue to work on a fix, but I'm not super familiar with the windows APIs so It will probably take me a while. |
charmbracelet/bubbletea#565 will improve the situation somewhat, as soon as we merge & bump the bubbletea dependency in gum. The redirection issues need to be addressed separately however. |
I've also figured out the redirection problem and realized it's an issue with the upstream |
One more upstream fix required to correctly reset |
Just in case nobody was aware: You can run the latest version of PowerShell on Linux and Mac because Microsoft made it portable a while ago. Note that Windows still ships older versions of PowerShell and the terminal program (the one with the blue background which came before Windows Terminal, it's called "something host" or so), so it's up to developers and users to teach narrow minded people who deem the bare Windows OS as a sufficient OS solution that it's actually like running a recent Linux kernel with bash 2.x and KDE 3.0.x or Gnome 2.x. When you look around in the PowerShell Github organization you will find some pretty interesting things which only work with recent versions of PowerShell. I'm just a Linux admin passing by who wrote his first few lines of PowerShell scripts to customize the OOTB experience of Windows 11 with winget and a few settings (Registry, Windows features) a few weeks ago. |
Will removing console dep completely help with powershell issues? |
came here to say I'm finding the same issue when piping variable assignments from gum filter on powershell 7 on windows 11 |
Any solution? Quite a downer to not have this |
My upstream fixes have been merged, so pretty much all of this is working fine now. |
Latest release does include Windows support now (thanks to @muesli): https://github.com/charmbracelet/gum/releases/tag/v0.10.0 I believe we can close this issue 😄 |
@maaslalani I hate to be that guy.. but it does not work in Cygwin 😭😭😭 Powershell confirmed working |
@maaslalani the issue still perists for me in and the error appreciate your help |
@alexn-s if you're experiencing the same thing as i am, the the value returned is actually multiple strings. see my gif below - I've thought about how I'd go about this between now and when I first ran into it in february (prior to the fix in build 0f0f8e9). to show what I'm seeing when I use gum input as you showed, I'm calling gum input then piping it to a foreach ternary which then uses an expression to print the returned strings wrapped with green text to emphasize the string separations. gum input \
--placeholder "Tell me something nice." | % { echo "$(gum style --foreground="#00fff" "String in series of strings ->") $_ $(gum style --foreground="#00fff" "<-- end of String")" } This is what I see: if you're experiencing the same thing, then maybe you could add an eleement to your script to remove any Strings that match the error message? that being said, ultimately the best case would be to update to v0.10.0 - that fixed it on my end (if you used scoop, it's just |
@Jonathan-Zollinger thanks for your response and the snippet i just noticed that i had gum 0.10 & 0.8 installed WARN 'charm-gum' (0.10.0) is already installed.
Use 'scoop update charm-gum' to install a new version.
2023-05_hot-script > gum --version
gum version v0.8.0 (dfa412f) that is why i was confused that it was not working for me. thank you |
\o I started work last night to make a Chocolatey package for gum since there's a build for Windows. I've been able to get the package sorted out but I started running into problems when I tried writing some example use cases.
Error Examples
Example 1: No Redirection or Assignment
Calling a gum command without doing anything else seems to work exactly as expected.
Example 2: Variable Assignment
Attempting to set assign a gum command's stdout to a variable seems to misbehave.
The prompt is munged with leading whitespace on the second line. I haven't run this down yet but I think this is related to the bubbletea model and some strange interaction when the console tries to go back to regular flow.
The output has an error prepended.
I expect to see:
but instead see (leading whitespace trimmed):
Doing a little digging, this appears to come from containerd/console:
https://github.com/containerd/console/blob/21ccd90b850f542a0b5a4fee0f5cb2e9b7bd7496/console_windows.go#L54
It seems this has been a pain point for Windows users of docker compose:
Though that issue is closed, there are re-reports from this year.
Example 3: Output Redirection
Attempting to redirect a gum command's stdout to a file has apparently identical behavior to assigning it to a variable.
Context
I'm a huge fan of your libraries and tools. I saw gum and immediately thought that it would be great for interactive scripts and would obviate a lot of work to get even an approximately similar UX for folks. I started thinking about a PowerShell module that wraps gum to provide a more familiar (to PowerShell developers) DevX.
If the captured output problem is intractable, I'm happy to write PowerShell handlers to hide away the implementation (strip the error message, etc). What that can't fix (I think) is the prompt munging.
I also noticed that there are completers for other shells and would love to see a completer for PowerShell (and be happy to try my hand at contributing one). I filed this all together as a single issue but if there's a desire to address these Windows-and-PowerShell-specific items, I'm also happy to file separate issues and link to them here as a pseudo-epic.
I'm also happy to help debug/troubleshoot, though my go skills are still nascent.
The text was updated successfully, but these errors were encountered: