395 lines
13 KiB
Markdown
395 lines
13 KiB
Markdown
## Setup
|
||
### New tab as Administrator
|
||
- [使用系統管理員身分開啟 Windows Terminal 分頁](https://blog.poychang.net/run-windows-terminal-as-administrator-with-elevated-admin-permissions/)
|
||
|
||
### Use powerline in Git-Bash
|
||
- [Light & simple powerline theme for Git bash for windows](https://github.com/diesire/git_bash_windows_powerline)
|
||
|
||
#### Install
|
||
```shell
|
||
cd $HOME
|
||
mkdir -p .bash/themes/git_bash_windows_powerline
|
||
git clone https://github.com/diesire/git_bash_windows_powerline.git .bash/themes/git_bash_windows_powerline
|
||
```
|
||
|
||
And add following lines to `~/.bashrc`.
|
||
```
|
||
# Theme
|
||
THEME=$HOME/.bash/themes/git_bash_windows_powerline/theme.bash
|
||
if [ -f $THEME ]; then
|
||
. $THEME
|
||
fi
|
||
unset THEME
|
||
```
|
||
|
||
參考:
|
||
- [powerline/fonts: Patched fonts for Powerline users.](https://github.com/powerline/fonts)
|
||
|
||
## Settings.json
|
||
```json
|
||
{
|
||
"$help": "https://aka.ms/terminal-documentation",
|
||
"$schema": "https://aka.ms/terminal-profiles-schema",
|
||
"actions":
|
||
[
|
||
{
|
||
"command":
|
||
{
|
||
"action": "prevTab"
|
||
},
|
||
"keys": "ctrl+pgup"
|
||
},
|
||
{
|
||
"command":
|
||
{
|
||
"action": "copy",
|
||
"singleLine": false
|
||
},
|
||
"keys": "ctrl+c"
|
||
},
|
||
{
|
||
"command":
|
||
{
|
||
"action": "splitPane",
|
||
"split": "right"
|
||
},
|
||
"keys": "ctrl+shift+e"
|
||
},
|
||
{
|
||
"command": "find",
|
||
"keys": "ctrl+shift+f"
|
||
},
|
||
{
|
||
"command": "paste",
|
||
"keys": "ctrl+v"
|
||
},
|
||
{
|
||
"command":
|
||
{
|
||
"action": "splitPane",
|
||
"split": "auto",
|
||
"splitMode": "duplicate"
|
||
},
|
||
"keys": "alt+shift+d"
|
||
},
|
||
{
|
||
"command": "toggleFullscreen",
|
||
"keys": "alt+x"
|
||
},
|
||
{
|
||
"command":
|
||
{
|
||
"action": "newTab"
|
||
},
|
||
"keys": "ctrl+t"
|
||
},
|
||
{
|
||
"command": "closePane",
|
||
"keys": "ctrl+w"
|
||
},
|
||
{
|
||
"command":
|
||
{
|
||
"action": "splitPane",
|
||
"split": "down"
|
||
},
|
||
"keys": "ctrl+shift+o"
|
||
},
|
||
{
|
||
"command":
|
||
{
|
||
"action": "nextTab"
|
||
},
|
||
"keys": "ctrl+pgdn"
|
||
}
|
||
],
|
||
"copyFormatting": "none",
|
||
"copyOnSelect": false,
|
||
// Start position
|
||
"initialCols": 234,
|
||
"initialRows": 30,
|
||
"initialPosition": "16,950", // x,y
|
||
"defaultProfile": "{00000000-0000-0000-ba54-000000000002}",
|
||
"profiles":
|
||
{
|
||
"defaults": {},
|
||
"list":
|
||
[
|
||
{
|
||
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
|
||
"hidden": false,
|
||
"name": "Windows PowerShell"
|
||
},
|
||
{
|
||
"colorScheme": "Solarized Dark",
|
||
"commandline": "gsudo.exe powershell.exe",
|
||
"font":
|
||
{
|
||
"face": "Fira Code"
|
||
},
|
||
"guid": "{41dd7a51-f0e1-4420-a2ec-1a7130b7e950}",
|
||
"hidden": false,
|
||
"icon": "C:\\Users\\awinh\\OneDrive\\\u5716\u7247\\icon\\console_red.png",
|
||
"name": "Windows PowerShell(Administrator)"
|
||
},
|
||
{
|
||
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
|
||
"hidden": false,
|
||
"name": "Command Prompt"
|
||
},
|
||
{
|
||
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
|
||
"hidden": false,
|
||
"name": "Azure Cloud Shell",
|
||
"source": "Windows.Terminal.Azure"
|
||
},
|
||
{
|
||
"commandline": "%PROGRAMFILES%/git/usr/bin/bash.exe -i -l",
|
||
"font":
|
||
{
|
||
"face": "CaskaydiaCove NF",
|
||
"size": 12
|
||
},
|
||
"guid": "{00000000-0000-0000-ba54-000000000002}",
|
||
"historySize": 9000,
|
||
"icon": "%PROGRAMFILES%/Git/mingw64/share/git/git-for-windows.ico",
|
||
"name": "Bash",
|
||
"startingDirectory": "C:\\Users\\awinh\\OneDrive\\codes"
|
||
}
|
||
]
|
||
},
|
||
"schemes":
|
||
[
|
||
{
|
||
"background": "#0C0C0C",
|
||
"black": "#0C0C0C",
|
||
"blue": "#0037DA",
|
||
"brightBlack": "#767676",
|
||
"brightBlue": "#3B78FF",
|
||
"brightCyan": "#61D6D6",
|
||
"brightGreen": "#16C60C",
|
||
"brightPurple": "#B4009E",
|
||
"brightRed": "#E74856",
|
||
"brightWhite": "#F2F2F2",
|
||
"brightYellow": "#F9F1A5",
|
||
"cursorColor": "#FFFFFF",
|
||
"cyan": "#3A96DD",
|
||
"foreground": "#CCCCCC",
|
||
"green": "#13A10E",
|
||
"name": "Campbell",
|
||
"purple": "#881798",
|
||
"red": "#C50F1F",
|
||
"selectionBackground": "#FFFFFF",
|
||
"white": "#CCCCCC",
|
||
"yellow": "#C19C00"
|
||
},
|
||
{
|
||
"background": "#012456",
|
||
"black": "#0C0C0C",
|
||
"blue": "#0037DA",
|
||
"brightBlack": "#767676",
|
||
"brightBlue": "#3B78FF",
|
||
"brightCyan": "#61D6D6",
|
||
"brightGreen": "#16C60C",
|
||
"brightPurple": "#B4009E",
|
||
"brightRed": "#E74856",
|
||
"brightWhite": "#F2F2F2",
|
||
"brightYellow": "#F9F1A5",
|
||
"cursorColor": "#FFFFFF",
|
||
"cyan": "#3A96DD",
|
||
"foreground": "#CCCCCC",
|
||
"green": "#13A10E",
|
||
"name": "Campbell Powershell",
|
||
"purple": "#881798",
|
||
"red": "#C50F1F",
|
||
"selectionBackground": "#FFFFFF",
|
||
"white": "#CCCCCC",
|
||
"yellow": "#C19C00"
|
||
},
|
||
{
|
||
"background": "#282C34",
|
||
"black": "#282C34",
|
||
"blue": "#61AFEF",
|
||
"brightBlack": "#5A6374",
|
||
"brightBlue": "#61AFEF",
|
||
"brightCyan": "#56B6C2",
|
||
"brightGreen": "#98C379",
|
||
"brightPurple": "#C678DD",
|
||
"brightRed": "#E06C75",
|
||
"brightWhite": "#DCDFE4",
|
||
"brightYellow": "#E5C07B",
|
||
"cursorColor": "#FFFFFF",
|
||
"cyan": "#56B6C2",
|
||
"foreground": "#DCDFE4",
|
||
"green": "#98C379",
|
||
"name": "One Half Dark",
|
||
"purple": "#C678DD",
|
||
"red": "#E06C75",
|
||
"selectionBackground": "#FFFFFF",
|
||
"white": "#DCDFE4",
|
||
"yellow": "#E5C07B"
|
||
},
|
||
{
|
||
"background": "#FAFAFA",
|
||
"black": "#383A42",
|
||
"blue": "#0184BC",
|
||
"brightBlack": "#4F525D",
|
||
"brightBlue": "#61AFEF",
|
||
"brightCyan": "#56B5C1",
|
||
"brightGreen": "#98C379",
|
||
"brightPurple": "#C577DD",
|
||
"brightRed": "#DF6C75",
|
||
"brightWhite": "#FFFFFF",
|
||
"brightYellow": "#E4C07A",
|
||
"cursorColor": "#4F525D",
|
||
"cyan": "#0997B3",
|
||
"foreground": "#383A42",
|
||
"green": "#50A14F",
|
||
"name": "One Half Light",
|
||
"purple": "#A626A4",
|
||
"red": "#E45649",
|
||
"selectionBackground": "#FFFFFF",
|
||
"white": "#FAFAFA",
|
||
"yellow": "#C18301"
|
||
},
|
||
{
|
||
"background": "#002B36",
|
||
"black": "#002B36",
|
||
"blue": "#268BD2",
|
||
"brightBlack": "#073642",
|
||
"brightBlue": "#839496",
|
||
"brightCyan": "#93A1A1",
|
||
"brightGreen": "#586E75",
|
||
"brightPurple": "#6C71C4",
|
||
"brightRed": "#CB4B16",
|
||
"brightWhite": "#FDF6E3",
|
||
"brightYellow": "#657B83",
|
||
"cursorColor": "#FFFFFF",
|
||
"cyan": "#2AA198",
|
||
"foreground": "#839496",
|
||
"green": "#859900",
|
||
"name": "Solarized Dark",
|
||
"purple": "#D33682",
|
||
"red": "#DC322F",
|
||
"selectionBackground": "#FFFFFF",
|
||
"white": "#EEE8D5",
|
||
"yellow": "#B58900"
|
||
},
|
||
{
|
||
"background": "#FDF6E3",
|
||
"black": "#002B36",
|
||
"blue": "#268BD2",
|
||
"brightBlack": "#073642",
|
||
"brightBlue": "#839496",
|
||
"brightCyan": "#93A1A1",
|
||
"brightGreen": "#586E75",
|
||
"brightPurple": "#6C71C4",
|
||
"brightRed": "#CB4B16",
|
||
"brightWhite": "#FDF6E3",
|
||
"brightYellow": "#657B83",
|
||
"cursorColor": "#002B36",
|
||
"cyan": "#2AA198",
|
||
"foreground": "#657B83",
|
||
"green": "#859900",
|
||
"name": "Solarized Light",
|
||
"purple": "#D33682",
|
||
"red": "#DC322F",
|
||
"selectionBackground": "#FFFFFF",
|
||
"white": "#EEE8D5",
|
||
"yellow": "#B58900"
|
||
},
|
||
{
|
||
"background": "#000000",
|
||
"black": "#000000",
|
||
"blue": "#3465A4",
|
||
"brightBlack": "#555753",
|
||
"brightBlue": "#729FCF",
|
||
"brightCyan": "#34E2E2",
|
||
"brightGreen": "#8AE234",
|
||
"brightPurple": "#AD7FA8",
|
||
"brightRed": "#EF2929",
|
||
"brightWhite": "#EEEEEC",
|
||
"brightYellow": "#FCE94F",
|
||
"cursorColor": "#FFFFFF",
|
||
"cyan": "#06989A",
|
||
"foreground": "#D3D7CF",
|
||
"green": "#4E9A06",
|
||
"name": "Tango Dark",
|
||
"purple": "#75507B",
|
||
"red": "#CC0000",
|
||
"selectionBackground": "#FFFFFF",
|
||
"white": "#D3D7CF",
|
||
"yellow": "#C4A000"
|
||
},
|
||
{
|
||
"background": "#FFFFFF",
|
||
"black": "#000000",
|
||
"blue": "#3465A4",
|
||
"brightBlack": "#555753",
|
||
"brightBlue": "#729FCF",
|
||
"brightCyan": "#34E2E2",
|
||
"brightGreen": "#8AE234",
|
||
"brightPurple": "#AD7FA8",
|
||
"brightRed": "#EF2929",
|
||
"brightWhite": "#EEEEEC",
|
||
"brightYellow": "#FCE94F",
|
||
"cursorColor": "#000000",
|
||
"cyan": "#06989A",
|
||
"foreground": "#555753",
|
||
"green": "#4E9A06",
|
||
"name": "Tango Light",
|
||
"purple": "#75507B",
|
||
"red": "#CC0000",
|
||
"selectionBackground": "#FFFFFF",
|
||
"white": "#D3D7CF",
|
||
"yellow": "#C4A000"
|
||
},
|
||
{
|
||
"background": "#000000",
|
||
"black": "#000000",
|
||
"blue": "#000080",
|
||
"brightBlack": "#808080",
|
||
"brightBlue": "#0000FF",
|
||
"brightCyan": "#00FFFF",
|
||
"brightGreen": "#00FF00",
|
||
"brightPurple": "#FF00FF",
|
||
"brightRed": "#FF0000",
|
||
"brightWhite": "#FFFFFF",
|
||
"brightYellow": "#FFFF00",
|
||
"cursorColor": "#FFFFFF",
|
||
"cyan": "#008080",
|
||
"foreground": "#C0C0C0",
|
||
"green": "#008000",
|
||
"name": "Vintage",
|
||
"purple": "#800080",
|
||
"red": "#800000",
|
||
"selectionBackground": "#FFFFFF",
|
||
"white": "#C0C0C0",
|
||
"yellow": "#808000"
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
## oh-my-posh on bash
|
||
以下步驟都是在 [Windows Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701) 中的 Git bash[^1] 執行。
|
||
1. 先下載一個你喜歡的theme: [https://ohmyposh.dev/docs/themes](https://ohmyposh.dev/docs/themes)
|
||
2. 下載並安裝字型:[Caskaydia Cove Nerd Font](https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/CascadiaCode.zip?WT.mc_id=-blog-scottha)
|
||
3. Install OhMyPosh: `winget install JanDeDobbeleer.OhMyPosh`
|
||
4. 建立並修改 `~/.profile`,然後加入
|
||
`eval "$(oh-my-posh --init --shell bash --config ~/OneDrive/appConfigs/ohmyposh/themes/montys.omp.json)"`
|
||
注意最後的 `montys.omp.json` 就是第一步下載的theme,這邊要改成你自己的路徑。
|
||
5. 修改 Windows Terminal 的 setting.json,將字型改為 `CaskaydiaCove NF`
|
||
![[20220614221618_oh-my-posh_setting.png|600]]
|
||
6. 成果
|
||
![[20220614220342_oh-my-posh_result.png|600]]
|
||
|
||
[^1]: 在 [Windows Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701) 中設定 Git bash 可以參考:[Windows Terminal's 設定 Git Bash 和 SSH @ 傑克! 真是太神奇了! :: 痞客邦 ::](https://magicjackting.pixnet.net/blog/post/225162505-windows-terminal's-%E8%A8%AD%E5%AE%9A-git-bash-%E5%92%8C-ssh)
|
||
|
||
## Reference
|
||
- [Windows Terminal 美化 for WSL 2 Ubuntu (zsh + zim + powerlevel10k)](http://www.kenming.idv.tw/windows-terminal-%e7%be%8e%e5%8c%96-for-wsl-2-ubuntu-zsh-zim-powerlevel10k/)
|
||
- [Oh My Posh](https://ohmyposh.dev/)
|
||
- [How to make the ultimate Terminal Prompt on Windows 11 - This video is LONG and WORDY and DETAILED - YouTube](https://www.youtube.com/watch?v=VT2L1SXFq9U)
|
||
- [My Ultimate PowerShell prompt with Oh My Posh and the Windows Terminal - Scott Hanselman's Blog](https://www.hanselman.com/blog/my-ultimate-powershell-prompt-with-oh-my-posh-and-the-windows-terminal)
|
||
- [Windows-Terminal配置OhMyPosh来美化GitBash_偕臧x的博客-CSDN博客](https://blog.csdn.net/qq_33154343/article/details/120661945)
|