windows开发环境配置

1. msys2 zsh on-my-zsh git vim shell winpty

  • 进入msys2官网,安装msys2
  • 修改源
  • 使用pacman安装zsh git vim shell winpty

    pacman -Sy zsh git vim shell winpty
    

2. 修改C:\msys64\msys2_shell.cmd

  • 修改set "LOGINSHELL=zsh"
  • 取消注释set MSYS=winsymlinks:nativestrict
  • 取消注释set MSYS2_PATH_TYPE=inherit

    set "LOGINSHELL=zsh"
    set /a msys2_shiftCounter=0
    
    rem To activate windows native symlinks uncomment next line
    set MSYS=winsymlinks:nativestrict
    
    rem Set debugging program for errors
    rem set MSYS=error_start:%WD%../../mingw64/bin/qtcreator.exe^|-debug^|^<process-id^>
    
    rem To export full current PATH from environment into MSYS2 use '-use-full-path' parameter
    rem or uncomment next line
    set MSYS2_PATH_TYPE=inherit
    

3. 修改~/.zshrc配置,winpty解决ping输出乱码问题

alias ping="/bin/winpty ping"
alias netstat="/bin/winpty netstat"
alias nslookup="/bin/winpty nslookup"
alias open="shell"

4. 解决on-my-zsh打开git目录卡顿、慢的问题

git config --global --add on-my-zsh.hide-dirty 1
git config  --global --add on-my-zsh.hide-status 1

取消置为1

5. 解决vscode源码管理器git不工作问题

  • 在/usr/bin/下面新建git-vscode.bat

    @echo off
    setlocal
    
    rem If you don't add path for msys2 into %PATH%, enable following line.
    set PATH=c:\msys64\usr\bin;%PATH%
    
    if "%1" equ "rev-parse" goto rev_parse
    git %*
    goto :eof
    :rev_parse
    for /f %%1 in ('git %*') do cygpath -w %%1% 
    
  • 修改setting.json

    "git.path": "c:/msys64/usr/bin/git-vscode.bat",
    
  • 重启vscode