[LINUX] 在 Win10 上搭建好用的終端開發環境:windows terminal + git bash + zsh + oh-my-zsh




1、安裝 git for windows

下載地址:https://gitforwindows.org,下載好之后,全部采用默認安裝。


2、安裝終端

Windows 上的終端有很多種,純 git-bash 不支持交互輸入(例如輸入 python 后一直卡着,不能出現 > ),這里介紹兩個可交互終端:

  • Windows Terminal (windows 上裝 Windows Terminal 不簡單,建議小白用戶用 Hyper)
  • Hyper

2.1 Windows Terminal

2.1.1 安裝 Windows Terminal

Microsoft Store,或從 Windows 開始菜單中啟動 Microsoft Store 應用程序並搜索 Terminal

注意: 注意不要選擇早期的 Windows Terminal Preview 應用程序。

注意: 其對 windows 版本有要求,需要更新系統(更新系統卡死在 99%,需要參考參考鏈接2;有些瀏覽器連易升都下載不了,建議用 google 瀏覽器)


2.1.2 設置 Windows Terminal
  • 啟動 Windows Terminal,點擊設置

  • 添加新配置文件->新增新配置->別忘了保存

  • 設置->選擇默認為 git bash


2.2 Hyper

2.2.1 安裝 Hyper

去 Hyper 官網下載:https://hyper.is 點擊下載

然后默認安裝即可。


2.2.2 配置 Hyper

右鍵打開 Hyper,然后菜單->Edit->Preferences,會彈出一個配置文件,在如下位置增加一行配置:

//
// Windows Subsystem for Linux (WSL) - previously Bash on Windows
// - Example: `C:\\Windows\\System32\\wsl.exe`
//
// Git-bash on Windows
// - Example: `C:\\Program Files\\Git\\bin\\bash.exe`
//
// PowerShell on Windows
// - Example: `C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`
//
// Cygwin
// - Example: `C:\\cygwin64\\bin\\bash.exe`
shell: 'C:\\Program Files\\Git\\bin\\bash.exe',    <---- 這里,這里,這里(這里的 bash.exe 就是第一步 git 安裝路徑)
// for setting shell arguments (i.e. for using interactive shellArgs: `['-i']`)
// by default `['--login']` will be used
shellArgs: ['--login'],
// for environment variables
env: {},
// Supported Options:
//  1. 'SOUND' -> Enables the bell as a sound
//  2. false: turns off the bell

配置好之后,保存重啟 Hyper,就會看到 Hyper 已經使用了 git-bash。


4、安裝 zsh

  • MSYS2 網站可以下載到最新的 zsh 安裝包:zsh-5.8-5-x86_64.pkg.tar.zst

  • 由於下載的是 zst 后綴文件,Windows 上需要安裝 PeaZip 工具(下載8.30以上版本)

  • 下載完成后解壓再解壓,可以看到文件如下:

  • 將這些文件直接解壓到 Git 的安裝目錄下,與之前的文件進行合並,可以理解為把 zsh 當作 git bash 的一個補充安裝包:

  • 此時我們打開 git bash,敲下 zsh,就會看到我們已經成功


5、安裝 Oh my zsh

在 zsh 里執行(curl)

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

或者用 wget

sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

最后,用 VIM 編輯 ~/.bashrc 文件,在其最后加入 zsh,表示終端打開默認執行 zsh。


參考鏈接

[1]. Windows Terminal完整指南
[2]. Windows 10更新失敗在百分99處卡住的處理方法
[3]. Install Terminal + git-bash + zsh + oh-my-zsh on Windows 10



: 陸續更新中...


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM