kelleyma49 / PSFzf

A PowerShell wrapper around the fuzzy finder fzf
MIT License
795 stars 36 forks source link

Escape sequence printed for CTRL-T, fe and fd commands #31

Closed Praful closed 2 years ago

Praful commented 4 years ago

When I use any of the CTRL-T, fe, or fd commands in ConEmu, PowerShell console or Windows Terminal, an escape sequence appears at the beginning and end of the line. I assume this is supposed to colour the line?

For example, CTRL-T gives:

 [0m[36m.File1.log[0m
 [0m[36m.File2.log[0m
...

And when I select one, the [0m[36m. and [0m are included in the selection, which I have to then delete.

I'm sure this used to work. I'm using PSFzF 1.1.26. Update-Module did not update it when I tried (in case there's a later version).

I've tried on PowerShell versions 5.1 and 6.2 running on Windows 10 1903.

I feel I'm doing something basically wrong! Please can you help correct this.

Thanks

Praful commented 4 years ago

Any comment on this? I get the same in CMD for PowerShell and Windows Terminal.

Thanks

Praful

kelleyma49 commented 4 years ago

Please update to 1.2.00 and let me know if you still see this issue. It would be helpful to have a stripped down version of your profile and a printout of your environment variables.

Praful commented 4 years ago

@kelleyma49 Thank you for looking at this issue.

I'm running 1.2.6 alpha since I'm testing its speed! This issue has existed for a quite a while.

I've simplified my profile to:

Set-PSReadlineOption -EditMode Vi
Remove-PSReadlineKeyHandler -chord Ctrl+r -vimode command
Remove-PSReadlineKeyHandler -chord Ctrl+t -vimode insert
Import-Module PSFzf -ArgumentList 'Ctrl+t','Ctrl+r'
Enable-PsFzfAliases 

I still get the escape sequences. with CTRL-T A red > appears and its line is coloured (with escape chars on either side).

Interestingly CTRL-R is fine with a red > and the line is coloured but there are no escape chars. Is there a difference between how the two are generating colours?

Other apps (such as ripgrep) use colours fine in the console.

My environment variables are below. I've removed some sensitive ones. I've tried unsetting TERM but can't from a console and I don't know where it's set.

ALLUSERSPROFILE=C:\ProgramData
COMMONPROGRAMFILES=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMSPEC=C:\WINDOWS\system32\cmd.exe
DATA=c:\data
DriverData=C:\Windows\System32\Drivers\DriverData
FZF_DEFAULT_COMMAND=rg --files --no-ignore --hidden --follow --glob "!.git/*"
HOME=/c/data/LinuxHome
IPYTHONDIR=c:\data\LinuxHome\.ipython
JAVA_HOME=c:\apps\java\jdk8\
LESS=--no-init --ignore-case --quit-if-one-screen --force --raw-control-chars
NUMBER_OF_PROCESSORS=4
OS=Windows_NT
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL
POWERSHELL_DISTRIBUTION_CHANNEL=MSI:Windows 10 Pro
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 78 Stepping 3, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=4e03
ProgramData=C:\ProgramData
PROGRAMFILES=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PUBLIC=C:\Users\Public
PYLINTRC=c:\data\LinuxHome\.pylintrc
PYTHONHOME=c:\apps\Python\latest3-64
RIPGREP_CONFIG_PATH=c:\data\settings\.ripgreprc
SYSTEMDRIVE=C:
SYSTEMROOT=C:\WINDOWS
TEMP=/tmp
TERM=ansi
TMP=/tmp
USERDOMAIN=PORTEGEZ30
WINDIR=C:\WINDOWS
__COMPAT_LAYER=DetectorsMessageBoxErrors
mattcargile commented 2 years ago

Ever get this solved @Praful ? I suspect the issue is fzf.exe doesn't have the --ansi flag or at least it didn't at one time.

I could repro what I think the behavior might have been with the below.

fd.exe --color=always | fzf

Or I could repro it with $env:FZF_DEFAULT_COMMAND = 'fd.exe --color=always' and calling CTRL + T.

Praful commented 2 years ago

@mattcargile - it's been a long time since I posted that! I'm no longer seeing the escape characters. I think the answer was to use --ansi in environment variable FZF_DEFAULT_OPTS. For the sake of completeness, my relevant environment variables are:

FZF_DEFAULT_COMMAND=rg --files --no-ignore --hidden --follow --glob "!.git/*"
FZF_DEFAULT_OPTS=--exact --ansi

HTH

mattcargile commented 2 years ago

Yeah that is what I surmised too. With rg and fd , when stdOut is piped the colors are removed in my experience; though I have only been using the software for 6 months or so. You have to add --color=always to get the color output when piped. Maybe that wasn't the case always. ( NOTE: I'd also check out fd --type file --hidden --no-ignore, though the author , burntsushi, says the search architecture is largely the same. The coloring is better though )

mattcargile commented 2 years ago

Maybe we can close this issue @Praful ?

Praful commented 2 years ago

👍🏽 @mattcargile