Skip to content

Conversation

@Avsilver
Copy link

@Avsilver Avsilver commented Jul 7, 2025

Description

Noice assumes users on windows will be using the default cmd.exe shell.
As someone who does all windows scripting through powershell, I have set configured my neovim shell to be pwsh

vim.o.shell = "pwsh"
vim.o.shellcmdflag = "-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command"
vim.o.shellpipe = "| Out-File -Encoding UTF8 %s"
vim.o.shellquote = ""
vim.o.shellredir = "| Out-File -Encoding UTF8 %s"
vim.o.shellxquote = ""

When using Powershell 7, colors are pushed to the output with the default variable

$PSStyle.OutputRendering = 'Host'

which colors the terminal screen using ANSI control characters

(ESC) Param Start (Position to color Param seperator) 1+ Instruction(color is typically m)
^[ [ 1-3 digits ; 1 alphabetical

Example:

**^[[30;1m **

When reading the terminal output, since these characters are being UTF8 encoded
through the shell piping, they are showing up in the notify message output.
It may be possible to turn the OutputRendering off, however, then there would
be no coloring whatsoever.

Resolution

In the same place where CR and LF are removed, add an extra check for ANSI characters

text = text:gsub("%^%[%[[%d;]*%a", "")

Screenshots

Working with CMD

image

Same command with pwsh as neovim shell

image

After filtering ANSI characters

image

@Avsilver Avsilver changed the title Removing ANSI Control sequences from message output: PWSH 7 fix: Removing ANSI Control sequences from message output: PWSH 7 Jul 7, 2025
@Avsilver Avsilver changed the title fix: Removing ANSI Control sequences from message output: PWSH 7 Fix Removing ANSI Control sequences from message output: PWSH 7 Jul 7, 2025
@Avsilver Avsilver changed the title Fix Removing ANSI Control sequences from message output: PWSH 7 fix(block) Removing ANSI Control sequences from message output: PWSH 7 Jul 7, 2025
@Avsilver Avsilver changed the title fix(block) Removing ANSI Control sequences from message output: PWSH 7 fix(block): Removing ANSI coloring control sequences from message output: pwsh7 Jul 7, 2025
@Avsilver Avsilver changed the title fix(block): Removing ANSI coloring control sequences from message output: pwsh7 fix(block): Removing ANSI coloring control sequences from message output Jul 7, 2025
@Avsilver Avsilver changed the title fix(block): Removing ANSI coloring control sequences from message output fix(block): removing ANSI coloring control sequences from message output Jul 7, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Aug 6, 2025

This PR is stale because it has been open 30 days with no activity.

@github-actions github-actions bot added the stale This issue or PR has been inactive for a while label Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale This issue or PR has been inactive for a while

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant