MicrosoftDocs / terminal

Creative Commons Attribution 4.0 International
470 stars 177 forks source link

The issue of abnormal opening of Chinese directories due to encoding problems #684

Closed kongfu-cat closed 1 year ago

kongfu-cat commented 1 year ago

what

Here's a solution to the GBK locale issue in Bash when opening a new tab in the same directory:

origin ref: https://learn.microsoft.com/en-us/windows/terminal/tutorials/new-tab-same-directory

PROMPT_COMMAND=${PROMPT_COMMAND:+"$PROMPT_COMMAND; "}'printf "\e]9;9;%s\e\\" "`cygpath -w "$PWD"`"'

to

PROMPT_COMMAND=${PROMPT_COMMAND:+"$PROMPT_COMMAND; "}'printf "\e]9;9;%s\e\\" "`cygpath -w "$PWD" -C ANSI`"'

how

cygpath -C

 -C, --codepage CP     print DOS, Windows, or mixed pathname in Windows
                        codepage CP.  CP can be a numeric codepage identifier,
                        or one of the reserved words ANSI, OEM, or UTF8.
                        If this option is missing, cygpath defaults to the
                        character set defined by the current locale.
nguyen-dows commented 1 year ago

Thanks for the help on this! I'll update the script in the docs!