这是本节的多页打印视图。 点击此处打印.

返回本页常规视图.

编程开发相关软件的安装和配置

windows11下编程开发相关软件的安装和配置

1 - 安装配置git

安装git,配置默认路径,设置字体大小

参考:

注意要配置好 git 的代理,否则容易被墙。

3 - 安装配置zsh

安装配置zsh和ohmyzsh!

备注:先确保已经安装配置好 git 和 gitbash。

安装配置 zsh

下载zsh

Zsh下载地址:

https://packages.msys2.org/package/zsh?repo=msys&variant=x86_64

下载 .tar.zst 文件:

https://mirror.msys2.org/msys/x86_64/zsh-5.9-2-x86_64.pkg.tar.zst

这个文件可以用 windows11 自带的解压缩软件就能解压缩,得到 zsh-5.9-2-x86_64.pkg 目录,里面有两个子目录:etc 和 usr 。

安装zsh

复制 etc 和 usr 目录,粘贴到 git 的安装目录如 D:\sky\work\soft\git ,git 安装目录下同样有 etc 和 usr 目录,文件会自动合并进去。

运行zsh

运行时,要先启动 git 自带的 bash 终端,然后执行 zsh 命令,也可以查看 zsh 版本:

$ zsh --version
zsh 5.9 (x86_64-pc-msys)

为了方便使用,尤其是用 zsh 替代 bash,可以修改 bash 的配置文件 ~/.bashrc (如果没有就创建它) ,加入内容:

/c/Windows/System32/chcp.com 65001 > /dev/null 2>&1

if [ -t 1 ]; then
  exec zsh
fi

这样就可以自动 bash 时自动启动 zsh。

第一次执行 zsh 时会询问文件创建的问题,选择

Quit and do nothing.  The function will be run again next time.

安装 Oh my zsh!

在 zsh 终端执行:

# 如果被墙则增加代理设置
# export all_proxy=socks5://192.168.2.1:7891

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

安装 wd 插件:

sh -c "$(curl -fsSL https://github.com/mfaerevaag/wd/raw/master/install.sh)"

配置以下插件:

git clone https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-history-substring-search.git $ZSH_CUSTOM/plugins/history-substring-search
git clone https://github.com/Pilaton/OhMyZsh-full-autoupdate.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/ohmyzsh-full-autoupdate

修改 zsh 配置

vi ~/.zshrc

注释掉这一行:

DISABLE_MAGIC_FUNCTIONS="true"

修改 plugins 为

plugins=(    
    git
    golang
    rust
    docker
    docker-compose 
    kubectl
    npm
    node
    mvn
    sudo
    helm
    redis-cli
    wd 
    zsh-autosuggestions
    zsh-syntax-highlighting
    history-substring-search
    ohmyzsh-full-autoupdate
)

# User configuration

ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor root line)
ZSH_HIGHLIGHT_PATTERNS=('rm -rf *' 'fg=white,bold,bg=red')

重启 zsh。

Updating plugins and themes Oh My ZSH
--------------------------------------

Updating Plugin — ohmyzsh-full-autoupdate -> https://github.com/Pilaton/OhMyZsh-full-autoupdate
Already up to date.

Updating Plugin — zsh-autosuggestions -> https://github.com/zsh-users/zsh-autosuggestions
Already up to date.

Updating Plugin — zsh-syntax-highlighting -> https://github.com/zsh-users/zsh-syntax-highlighting
Already up to date.

Updating Theme — powerlevel10k -> https://github.com/romkatv/powerlevel10k
Already up to date.

备注: 这个自动更新可能会因为 github.com 被墙无法访问而失败。可以修改 .zshrc 的设置,默认开启代理避免更新时被墙:

# auto start proxy on
export all_proxy=socks5://192.168.2.1:7891;export http_proxy=http://192.168.2.1:7890;export https_proxy=http://192.168.2.1:7890;export no_proxy=127.0.0.1,localhost,local,.local,.lan,192.168.0.0/16,10.0.0.0/16

然后手工更新 ohmyzsh:

# proxyon
omz update

执行完 ohmyzsh 的更新之后,关闭所有的终端,再重新打开,就会触发 zsh plugins 的自动更新。

配置网络代理

修改 zsh 配置

vi ~/.zshrc

增加以下内容:

# set proxy for different locations
alias proxyon-nansha='export all_proxy=socks5://192.168.0.1:7891;export http_proxy=http://192.168.0.1:7890;export https_proxy=http://192.168.0.1:7890;export no_proxy=127.0.0.1,localhost,local,.local,.lan,192.168.0.0/16,10.0.0.0/16'
alias proxyon-tianhe='export all_proxy=socks5://192.168.2.1:7891;export http_proxy=http://192.168.2.1:7890;export https_proxy=http://192.168.2.1:7890;export no_proxy=127.0.0.1,localhost,local,.local,.lan,192.168.0.0/16,10.0.0.0/16'
alias proxyon-fenghu='export all_proxy=socks5://192.168.3.1:7891;export http_proxy=http://192.168.3.1:7890;export https_proxy=http://192.168.3.1:7890;export no_proxy=127.0.0.1,localhost,local,.local,.lan,192.168.0.0/16,10.0.0.0/16'
alias proxyon-qingpu='export all_proxy=socks5://192.168.5.1:7891;export http_proxy=http://192.168.5.1:7890;export https_proxy=http://192.168.5.1:7890;export no_proxy=127.0.0.1,localhost,local,.local,.lan,192.168.0.0/16,10.0.0.0/16'
alias proxyon-local='export all_proxy=socks5://127.0.0.1:7897;export http_proxy=http://127.0.0.1:7897;export https_proxy=http://127.0.0.1:7897;export no_proxy=127.0.0.1,localhost,local,.local,.lan,192.168.0.0/16,10.0.0.0/16'
# set default proxy by this line
alias proxyon='proxyon-local'
alias proxyoff='unset all_proxy http_proxy https_proxy no_proxy'
# uncomment next line to enable proxy by default when zsh is opened
# proxyon

4 - 安装配置 golang

安装 golang 设置 gopath

参考: https://skyao.net/learning-hugo/docs/installation/windows/#%E5%AE%89%E8%A3%85golang

5 - 安装配置 Java

安装设置 jdk

安装 sdkman

安装 unzip

下载地址: https://sourceforge.net/projects/gnuwin32/files/zip/3.0/zip-3.0-bin.zip/download

解压下载的 zip-3.0-bin.zip 文件后,将 bin 目录下所有的文件都复制到 windows/system32 目录下。

备注:https://sourceforge.net/projects/gnuwin32/files/ 这里可以下载到很多支持 MinGW 环境的软件。

安装 sdkman

执行:

curl -s "https://get.sdkman.io" | bash

如果报错看错误信息提示,如果发现没有任何成功或者错误的信息就结束,然后 sdkman 也没能安装完成,就应该时过程中出错了。

可以先访问 https://get.sdkman.io 这个地址,将内容复制下来,在本地保存为 sdkman.sh。然后执行:

bash ./sdkman.sh

就可以看到日志信息。

备注: sdkman 安装时,需要访问 github,经常会因为墙而访问失败。注意设置好梯子。

安装 jdk

安装常用的四个 jdk 版本:

sdk install java 21.0.6-zulu
sdk install java 17.0.14-zulu
sdk install java 11.0.26-zulu 
sdk install java 8.0.442-zulu

安装 maven

最简单的办法就是直接用 sdkman 安装:

sdk install maven

输出为:

Downloading: maven 3.9.9

In progress...

############################################################################################################# 100.0%

Installing: maven 3.9.9
Done installing!


Setting maven 3.9.9 as default.

检查版本:

mvn --version
Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: C:\Users\sky\.sdkman\candidates\maven\current
Java version: 17.0.14, vendor: Azul Systems, Inc., runtime: C:\Users\sky\.sdkman\candidates\java\current
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"

6 - 安装配置 nodejs

安装 nodejs 和 npm

参考:https://skyao.net/learning-hugo/docs/installation/windows/#%E5%AE%89%E8%A3%85nodejsnpm

特别提醒:native modules 这里不要勾选!不然会自动安装一大堆的内容,包括 python/visual studio build tools 等。

7 - 安装配置 hugo

安装 hugo 和依赖软件

备注:在安装 hugo 前,确保已经先安装好了 git / golang / nodejs。markdown 编辑器可以选择 typora 或者直接用 vs code。

安装 hugo

参考: https://skyao.net/learning-hugo/docs/installation/windows/

备注:

  • nodejs 的安装遇到问题,下次再试试。不要自动安装 python。

配置 hugo

参考: https://skyao.net/learning-hugo/docs/installation/postinstall/

8 - 安装配置VS Code

安装VS Code

下载

https://code.visualstudio.com/download#

选择 windows 11 x64 版本下载。

安装

安装路径设置为 d:/sky/work/soft/vscode

安装完成后打开 vscode,设置为固定在任务栏上。

初始化配置

主题

启动后,在 Get Started 界面,“choose the look you want"中选择 “Brower Color themes”,然后选择 “solarized dark”,这是个人最喜欢的一个配色。

配置 git 插件

打开 git 仓库的项目后,vs code 报错说找不到 git,需要打开 vscode 的 settings,搜索 git.path ,按照提示在 settings.json 文件中加入 git.path 的设置,指向我们安装的 git:

{
    "workbench.colorTheme": "Solarized Dark",
    "git.path": "D:\\sky\\work\\soft\\git\\bin\\git.exe"
}