搭建完美的 Windows開發(fā)環(huán)境
搭建完美的 Windows開發(fā)環(huán)境
因工作原因,長期使用過 Ubuntu18.04、Windows7、Windows10 等系統(tǒng)用于程序開發(fā),唯一的缺憾就是沒有使用過 Mac。
本著 “工欲善其事必先利其器”、“顏值就是生產(chǎn)力” 的原則,我最偏愛的就是 Windows10(with WSL)。經(jīng)常有朋友問我,哈,你這是什么操作?好秀!你這是什么軟件?好棒!你這是什么鬼?還能跑 Linux?所以這里寫下來作為記錄,同時(shí)以饗讀者。
究竟哪個(gè)環(huán)境最適合作為開發(fā)環(huán)境,仁者見仁吧,畢竟這個(gè)問題就像是 Android 和 IOS 的引戰(zhàn)題一樣,還是那句話,適合自己的最好。
下面我將詳述自己的開發(fā)環(huán)境搭建過程,希望對(duì)大家有幫助。主要分為系統(tǒng)相關(guān)、終端、IDE、瀏覽器、文檔編輯、版本控制、效率工具等。
一:系統(tǒng)相關(guān)
首先你要有一個(gè) Windows10 操作系統(tǒng)。
推薦更改下背景和顏色,狂拽炫酷 :)
Win+i - 個(gè)性化 - 顏色

Ⅰ、安裝 WSL
之所以開篇提到 WSL,因?yàn)檫@是讓我最終放棄 Ubuntu 的根本原因。
Q:Linux 最好的發(fā)行版是那個(gè)?A:WIndows 10 with WSL :)
1 介紹
1.1 What is WSL?
這里是百度的詳細(xì)介紹:WSL 百度百科?簡單的說,就是以軟件的形式在 Win10 上運(yùn)行原生的 Linux。
1.2 Features of WSL
經(jīng)過近幾天的使用,WSL 具有以下特點(diǎn):
① Win10 和 Linux 文件共享,及可以相互操作彼此的文件;
② 基于上,可以在 Win10 運(yùn)行 Linux 命令;
③ 基于上,可以在 Linux 運(yùn)行 Win10 exe 程序;
1.3 Why use WSL?
基于上述 Features,我總結(jié) WSL 有如下三個(gè)用處:
① 使用純正的 Linux 模擬上線環(huán)境,運(yùn)行測(cè)試我們的代碼;
② 使用 Linux 的軟件環(huán)境 + Win IDE(VS Code & PyCharm 等)進(jìn)行開發(fā)(使用 Linux 的包管理工具,簡直開心的不能行);
③ 使用 PowerShell + zsh(bash)的完美終端組合;
④ 一共才 220M,你想啥 :)
1.4 Why Donot I use VMware?
看了 1.3,相信你肯定不愿意用虛擬機(jī)了。
2 安裝
安裝很簡單,這里簡單說下(下文基于 WSL1)。
如果你的系統(tǒng)版本支持 WSL2(Windows 內(nèi)部版本 19041 或更高版本),可直接安裝 WSL2,官網(wǎng)教程如下:
關(guān)于 WSL1 和 WSL2 的區(qū)別,官網(wǎng)對(duì)比如下:
WSL2 安裝 Docker 比較簡單,直接下載 windows 版本,會(huì)自動(dòng)提示你 Enable WSL2,勾選即可,可參考另一篇博文:
2.1 確保系統(tǒng)版本滿足
首先確保你的系統(tǒng)是較新的 Win10,以 Ubuntu 為例,該軟件僅支持 16237 及以上版本,如下圖:
查看本機(jī) Win10 版本方式:?Win + i?- 系統(tǒng) - 關(guān)于 - Windows 規(guī)格,比如我的是 18363
如果不滿足,更新即可。
2.2 啟動(dòng) WSL 功能
按照如下操作:搜索框輸入 “啟用或關(guān)閉 Windows 功能”,點(diǎn)開即可(實(shí)際上,僅僅輸入幾個(gè)拼音即可),如下圖:
勾選?適用于 Linux 的 Windows 子系統(tǒng),系統(tǒng)會(huì)自動(dòng)配置,然后重啟即可。
2.3 安裝
打開 Microsoft Store,輸入 wsl,搜索。點(diǎn)擊獲取這些應(yīng)用,如下圖:
如下是列出的所有 WSL 應(yīng)用,可以選擇自己喜歡的系統(tǒng),這里我選擇的 Ubuntu。進(jìn)去,點(diǎn)擊安裝即可。220M,很快就可以完成。
3 使用
安裝完成之后,就是愉快而興奮的使用環(huán)節(jié)了,首先在開始中點(diǎn)擊 Ubuntu,經(jīng)過幾分鐘的 install,配置 user 和 password 即可。

下面開始詳細(xì)環(huán)境搭建。
3.1 更新源
熟悉的套路來了 。。。首先更換為阿里云的 apt 源。
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo vim /etc/apt/sources.list
刪除內(nèi)容,并添加 20.04 源:
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
執(zhí)行 update 和 upgrade
sudo apt update
sudo apt upgrade
3.2 安裝 Nodejs、Mysql 等
這里扔兩個(gè)鏈接,Python3、git、ssh 有自帶的,就不說了。?Nodejs 安裝?Ubuntu 安裝 Mysql
3.3 安裝 zsh&oh_my_zsh
bash 雖好,我用 zsh?zsh 安裝配置?oh_my_zsh?使用指南
4 使用 WSL 開發(fā)
4.1 VScode with WSL
安裝完 WSL 之后,打開 VSCode,就會(huì)提示你安裝 Remote WSL,安裝即可。
安裝完,左下角會(huì)有一個(gè)綠色的 WSL 標(biāo)志。
點(diǎn)擊綠色標(biāo)志,選擇 New Window,就會(huì)自動(dòng)配置
我們嘗試運(yùn)行一個(gè) js 文件(需要我們?cè)?Ubuntu 中創(chuàng)建一個(gè) test.js 文件):

我們?cè)倏纯?terminal,美滋滋啊~
4.2 Pycharm with WSL
雖然 VSCode 也可以運(yùn)行 python,但還是覺得用 Pycharm 更爽。Pycharm 也可以使用 WSL 里的 python 環(huán)境進(jìn)行開發(fā),如下操作:setting - Project Interpreter - Add 修改為 WSL 即可,如下圖:

WSL - 選擇 Ubuntu 的 python3 即可。
運(yùn)行即可,哇,真的美滋滋啊,你甚至不需要在 Ubuntu 里去創(chuàng)建一個(gè) py 文件。同樣,我們看下 terminal,發(fā)現(xiàn)是 Windows 的命令行,沒關(guān)系,一個(gè) bash 命令,美滋滋。

Ⅱ Windows Terminal
Windows 自帶的 CMD 實(shí)在是丑且不好用,Powershell 中規(guī)中矩,cmder 算是不錯(cuò),但相信我,Windows Terminal 算得上我用過最舒服的 Windows 環(huán)境下的 terminal,而且安裝簡單。
在 Microsoft Store 中下載 Windows Terminal 即可。

打開后,可以呼出自己想要的終端,當(dāng)然,你在 Windows PS or cmd 中,直接輸入 bash,也可以直接進(jìn)入 bash。

另外,給大家推薦一款自己特別喜歡的字體:FiraCode.
該字體 l(L) 和 I(i) 區(qū)分很明顯,大于等于等可以連在一起顯示,且顏值很高,筆者的所有的 IDE、文本編輯器、Terminal 都是使用的這個(gè)字體,效果如圖:
順便貼下筆者的 Windows Terminal 配置:
// This file was initially generated by Windows Terminal 1.4.3243.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
// You can add more global application settings here.
// To learn more about global settings, visit https://aka.ms/terminal-global-settings
// If enabled, selections are automatically copied to your clipboard.
"copyOnSelect": true,
// If enabled, formatted data is also copied to your clipboard
"copyFormatting": false,
// A profile specifies a command to execute paired with information about how it should look and feel.
// Each one of them will appear in the 'New Tab' dropdown,
// and can be invoked from the commandline with `wt.exe -p xxx`
// To learn more about profiles, visit https://aka.ms/terminal-profile-settings
"profiles":
{
"defaults":
{
// Put settings here that you want to apply to all profiles.
"fontFace": "Fira Code",
"fontSize": 11,
"startingDirectory": "./"
},
"list":
[
{
// Make changes here to the powershell.exe profile.
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false,
"useAcrylic" : true,
"acrylicOpacity" : 0.75,
"colorScheme" : "Afterglow"
},
{
// Make changes here to the cmd.exe profile.
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "Command Prompt",
"commandline": "cmd.exe",
"hidden": false,
"useAcrylic" : true,
"acrylicOpacity" : 0.75,
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
// "hidden": false,
"hidden": true,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
},
{
"guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
"hidden": false,
"name": "Ubuntu-20.04",
"source": "Windows.Terminal.Wsl"
},
{
"guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"hidden": false,
"name": "Ubuntu",
"source": "Windows.Terminal.Wsl",
"useAcrylic" : true,
"acrylicOpacity" : 0.75,
"colorScheme" : "ubt"
}
]
},
// Add custom color schemes to this array.
// To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
"schemes": [
{
"name": "Afterglow",
"black": "#151515",
"red": "#ac4142",
"green": "#7e8e50",
"yellow": "#e5b567",
"blue": "#6c99bb",
"purple": "#9f4e85",
"cyan": "#7dd6cf",
"white": "#d0d0d0",
"brightBlack": "#505050",
"brightRed": "#ac4142",
"brightGreen": "#7e8e50",
"brightYellow": "#e5b567",
"brightBlue": "#6c99bb",
"brightPurple": "#9f4e85",
"brightCyan": "#7dd6cf",
"brightWhite": "#f5f5f5",
"background": "#001c33",
// "background": "#212121",
"foreground": "#d0d0d0"
},
{
"name": "ubt",
"black": "#151515",
"red": "#ac4142",
"green": "#7e8e50",
"yellow": "#e5b567",
"blue": "#6c99bb",
"purple": "#9f4e85",
"cyan": "#7dd6cf",
"white": "#d0d0d0",
"brightBlack": "#505050",
"brightRed": "#ac4142",
"brightGreen": "#7e8e50",
"brightYellow": "#e5b567",
"brightBlue": "#6c99bb",
"brightPurple": "#9f4e85",
"brightCyan": "#7dd6cf",
"brightWhite": "#f5f5f5",
//"background": "#2f0012",
"background": "#212121",
"foreground": "#d0d0d0"
},
],
// Add custom actions and keybindings to this array.
// To unbind a key combination from your defaults.json, set the command to "unbound".
// To learn more about actions and keybindings, visit https://aka.ms/terminal-keybindings
"actions":
[
// Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
// These two lines additionally bind them to Ctrl+C and Ctrl+V.
// To learn more about selection, visit https://aka.ms/terminal-selection
{ "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
{ "command": "paste", "keys": "ctrl+v" },
// Press Ctrl+Shift+F to open the search box
{ "command": "find", "keys": "ctrl+shift+f" },
// Press Alt+Shift+D to open a new pane.
// - "split": "auto" makes this pane open in the direction that provides the most surface area.
// - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
// To learn more about panes, visit https://aka.ms/terminal-panes
{ "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }
]
}
如果,你更習(xí)慣于使用 Windows PS,但是你又覺得界面丑陋,這里有美化教程。?WPS 美化?Windows Terminal 也是微軟開發(fā)的,微軟出品,必屬精品啊。
微軟鎮(zhèn)貼
二:IDE 相關(guān)
Ⅰ IDEA 全家桶
IntelliJ IDEA、Pycharm 等不多說了,唯獨(dú)是激活碼的問題,建議支持正版,我不會(huì)告訴你淘寶有十塊錢一年的激活碼。
Ⅱ Anaconda
用于數(shù)據(jù)分析,簡直不要太開心。
Ⅲ VS Code
微軟出品,必屬精品。
Ⅳ 數(shù)據(jù)庫相關(guān)
4.1 Navicat Premium
Mysql 請(qǐng)認(rèn)準(zhǔn) Navicat
4.3 PLSQL developer
Oracle 推薦使用 PLSQL,搭配自定義快捷輸入,效率簡直可以上天了。
三:瀏覽器
這里主要說下我用的瀏覽器和相關(guān)插件,Emm,莫得插件的瀏覽器莫得靈魂。
0 Edge
知友推薦的,同樣基于 Chromium 內(nèi)核,個(gè)人感覺比 Chrome 好用。體現(xiàn)在:
優(yōu)點(diǎn):
①啟動(dòng)速度極快;
②可以訪問微軟服務(wù),書簽和插件方便同步下載等;
③基于 Chromium 內(nèi)核,插件通用;
④可直接安裝 Chrome 官網(wǎng)插件:最近發(fā)現(xiàn),Edge 直接訪問 Chrome 的?Chrome 插件官網(wǎng)也可以直接安裝插件。
缺點(diǎn):
①Linux 版目前只是內(nèi)測(cè)版,尚不支持?jǐn)?shù)據(jù)同步。
ⅠChrome
這個(gè)不解釋了,推薦大家科學(xué)上網(wǎng),下載官網(wǎng)的版本,不然可能遇到無法正常升級(jí)的情況。
這里主要說下插件。


1.1 某插件
違反規(guī)定,不寫了。
1.2 Dark Reader
Dark Reader 可以全局黑色,同時(shí)配上 Chrome 黑色主題,完美!

1.3 Https Everywhere
使用 https 請(qǐng)求,保證數(shù)據(jù)隱私安全。
1.4 Infinity 新標(biāo)簽頁 Pro
使用過最好用的瀏覽器首頁,見上圖。
1.4?JSON Viewer Pro
最好用的 json 格式化工具。


1.5 Talend API Tester
類似于 Postman 和 restclient,并且非常好用。

1.6 油猴 TamperMonkey
神器啊,必須要有,列下我常用的腳本:
值得注意的是,有些腳本可能會(huì)影響原本的網(wǎng)頁功能,比如我使用的某些腳本會(huì)影響知乎的復(fù)制功能,所以大家不要盲目的添加腳本,要根據(jù)自己的需求來。
1.7 簡悅?SimpRead - Reader View
代碼高亮、大圖查看等等插件,使閱讀真的成了一種享受。對(duì) CSDN、博客園、簡書等有很好的支持,放個(gè)比較圖:

1.8?MathJax Plugin for Github
目前 Github 暫不支持 LaTex 數(shù)學(xué)公式的渲染,通過安裝該公式可以在 Github 完美顯示數(shù)學(xué)公式。
Ⅱ Firefox
開源的瀏覽器,尤其讓人放心。但請(qǐng)不要下載國內(nèi)廣告版本,請(qǐng)使用國際版。
同樣推薦下幾款插件:
2.1 RestClient
2.2?LatexMathifyGitHub
作用同 Chrome 的 MathJax Plugin for Github,均是用于 LaTex 公式渲染。
2.3 VivaldiFox
相信我,這款插件可以讓你的瀏覽器充滿生氣。
2.4 其余同 Chrome(如果 Firefox 有的話)
四 文檔編輯類
Ⅰ 文本編輯器
1.1 sublime Text
這款編輯器應(yīng)該是我用過最好用的編輯器,功能與顏值俱佳。
自定義快捷鍵
Ctrl+U 轉(zhuǎn)化為大寫
Ctrl+Shift+U 轉(zhuǎn)化為小寫
Preference - Key bindings
[
{ "keys": ["ctrl+u"], "command": "upper_case" },
{ "keys": ["ctrl+shift+u"], "command": "lower_case" },
]
自定義字體和樣式、替換 Tab 為 4 個(gè)空格、顯示編碼等(需要安裝 material theme)
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"color_scheme": "Packages/Material Theme/schemes/Material-Theme-Darker.tmTheme",
"dictionary": "Packages/Language - English/en_US.dic",
"font_face": "Fira Code",
"font_options":
[
"gray_antialias",
"subpixel_antialias"
],
"font_size": 11,
"ignored_packages":
[
"Vintage"
],
"indent_guide_options":
[
"draw_normal",
"draw_active"
],
"line_padding_bottom": 3,
"line_padding_top": 3,
"material_theme_accent_bright-teal": true,
"material_theme_accent_scrollbars": true,
"material_theme_bold_tab": true,
"material_theme_small_tab": true,
"material_theme_tabs_autowidth": true,
"overlay_scroll_bars": "enabled",
"show_encoding": true,
"show_line_endings": true,
"tab_size": 4,
"theme": "Material-Theme-Darker.sublime-theme",
"translate_tabs_to_spaces": true,
"word_wrap": true
}
這里推薦一些插件:
CTags?:可用于代碼跳轉(zhuǎn),實(shí)現(xiàn)類似于 IDEA 的 Ctrl + 單擊 的效果。
Sublimerge:顧名思義,文件比較。
Pretty JSON:顧名思義,快速格式化 JSON,快捷鍵為 Ctrl+Alt+J
Material Theme: 顏值即正義
主題推薦:
Material Theme:目前我的 sublime 界面如下:

該主題的配置文件為:
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"color_scheme": "Packages/Material Theme/schemes/Material-Theme-Darker.tmTheme",
"dictionary": "Packages/Language - English/en_US.dic",
"font_face": "Fira Code",
"font_options":
[
"gray_antialias",
"subpixel_antialias"
],
"font_size": 11,
"ignored_packages":
[
"Vintage"
],
"indent_guide_options":
[
"draw_normal",
"draw_active"
],
"line_padding_bottom": 3,
"line_padding_top": 3,
"material_theme_accent_bright-teal": true,
"material_theme_accent_scrollbars": true,
"material_theme_bold_tab": true,
"material_theme_small_tab": true,
"material_theme_tabs_autowidth": true,
"overlay_scroll_bars": "enabled",
"show_encoding": true,
"show_line_endings": true,
"tab_size": 4,
"theme": "Material-Theme-Darker.sublime-theme",
"translate_tabs_to_spaces": true,
"word_wrap": true
}
Sublime 的快捷鍵及其多,可以自行百度。
Ⅱ Notepad ++
最好用的 SQL 編輯器,沒有之一(前提是你要對(duì)快捷鍵很熟悉)。

Tab 替換為四個(gè)空格
Ⅲ Typora(最喜歡的 MarkDown 編輯器)
Emm,事實(shí)上,本文章,就是用 Typora 編寫的~

五 版本控制
我們沒得選,GIt SVN 搞起來吧。
六 效率工具
Ⅰ everything
搜索神器。
Ⅱ Motrix
開源的下載工具。
Ⅲ FDM
也是開源的下載工具,類似于 IDM。
最后最后,一定要熟練使用快捷鍵,不會(huì)快捷鍵的程序員靈魂
