--- title: windows 命令列環境設定 tags: zsh --- [toc] # Windodws Terminal ```bash winget install -e --id Microsoft.WindowsTerminal ``` # 快速鍵 * Ctrl + Shift + T 打開新標籤頁 * Ctrl + Shift + W 關閉分屏 * Ctrl + Shift + 數字鍵 進入第N個tab * Alt + Shift + - 橫向分屏 * Alt + Shift + + 縱向分屏 * Ctrl + + 放大 * Ctrl + - 縮小 * Ctrl + 0 恢復默認縮放比例 # 安装VSCode ```bash winget install -e --id Microsoft.VisualStudioCode Installing VS Code Server for Linux x64 ``` # 安装Docker Deskstop ```bash winget install -e --id Docker.DockerDesktop ``` # 需要管理員權限 win10 os version 18362.418 升級 如果您執行Windows 10 1903 版或 1909 版 請從Windows功能表中開啟 "設定" 瀏覽至 [更新 & 安全性],然後選取 [檢查更新] 您的組建編號必須是 18362.1049+ 或 18363.1049+ 次要組建號碼為 1049 * dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart * dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart * winget install -e --id Docker.DockerDesktop WSL2 Linux 核心更新套件 (適用於 x64 電腦): https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi ```shell= wsl --set-default-version 2 ``` # WSL2: Ubuntu-24.04 必要條件 您必須執行 Windows 10 2004 版和更高版本 (組建19041和更新版本的) 或 Windows 11 手動更新套件 https://docs.microsoft.com/zh-tw/windows/wsl/install-manual https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi ```shell= # 顯示本機已安裝的版本 wsl --list -v # 顯示目前可供安裝的版本 wsl --list --online # 安裝指定的版本 wsl --install -d Ubuntu-24.04 # 重設已安裝的版本 wsl --unregister Ubuntu-24.04 ``` # sudo指令不用密碼 ```shell= # 編輯/etc/sudoers sudo visudo # 新增指定賬號不用密碼,按 ctrl + x 存檔離開 # 第一個欄位輸入使用者賬號 armin ALL=(ALL:ALL) NOPASSWD:ALL ``` # apt update ```bash sudo apt-get update sudo apt-get upgrade -y ``` # 安裝編譯工具 ```bash sudo apt-get install build-essential -y ``` # 安裝zsh ```bash sudo apt install zsh -y ``` # 安裝oh-my-zsh 官網: https://ohmyz.sh/ github: https://github.com/ohmyzsh/ohmyzsh ```bash sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" ``` # 安裝oh-my-zsh plugin https://github.com/zsh-users/zsh-autosuggestions https://github.com/zsh-users/zsh-syntax-highlighting https://github.com/zsh-users/zsh-history-substring-search ```shell= # zsh-autosuggestions # 方向鍵 右 or End 鍵 全部補全 # ctrl + 方向鍵 右 or esc + f or option + f 向右逐一補全 # ctrl + 方向鍵 左 or esc + b or option + b 向左逐一返回 # ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=6,bg=7" # 顔色代碼搜尋 z-shell-colors git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions # zsh-syntax-highlighting # 高亮顯示正確或錯誤的指令 git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting # zsh-history-substring-search # 輸入指令片段后用快速鍵搜尋 # cat -v 觀察鍵盤輸入碼 # ctrl + up = ^[[1;5A # ctrl + down = ^[[1;5B # ctrl + u 停止搜尋 git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search # 編輯zsh設定檔 vi .zshrc ``` ```json= plugins=( # other plugins... zsh-autosuggestions zsh-syntax-highlighting zsh-history-substring-search ) ``` ```json= # bindkey要在此行之後 source $ZSH/oh-my-zsh.sh # ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=6,bg=7" # 顔色代碼搜尋 z-shell-colors # bindkey '^ ' autosuggest-accept # bindkey '^[[1;5A' history-substring-search-up # bindkey '^[[1;5B' history-substring-search-down # bind P and N for EMACS mode # bindkey -M emacs '^P' history-substring-search-up # bindkey -M emacs '^N' history-substring-search-down # bind k and j for VI mode # bindkey -M vicmd 'k' history-substring-search-up # bindkey -M vicmd 'j' history-substring-search-down ``` # 安裝字形 github: https://github.com/romkatv/powerlevel10k#meslo-nerd-font-patched-for-powerlevel10k * MesloLGS NF Regular.ttf * MesloLGS NF Bold.ttf * MesloLGS NF Italic.ttf * MesloLGS NF Bold Italic.ttf * windows terminal: - Ctrl+, -> 設定 -> 設定檔 -> 預設值 -> 外觀 -> 字體 -> MesloLGS NF * vscode: ```json { "editor.fontSize": 24, "terminal.integrated.fontFamily": "MesloLGS NF", "terminal.integrated.fontSize": 24 } ``` # 安裝powerlevel10k github: https://github.com/romkatv/powerlevel10k ```bash git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k ``` * Set ZSH_THEME="powerlevel10k/powerlevel10k" in ~/.zshrc. * p10k configure: 重新設定 powerlevel10k * Enable Transient Prompt => true
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up