461 lines
14 KiB
Markdown
461 lines
14 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": "splitPane",
|
||
"split": "down"
|
||
},
|
||
"id": "User.splitPane.D5151347"
|
||
},
|
||
{
|
||
"command":
|
||
{
|
||
"action": "copy",
|
||
"singleLine": false
|
||
},
|
||
"id": "User.copy.644BA8F2"
|
||
},
|
||
{
|
||
"command":
|
||
{
|
||
"action": "prevTab"
|
||
},
|
||
"id": "User.prevTab.0"
|
||
},
|
||
{
|
||
"command":
|
||
{
|
||
"action": "splitPane",
|
||
"split": "right"
|
||
},
|
||
"id": "User.splitPane.864CD510"
|
||
},
|
||
{
|
||
"command": "paste",
|
||
"id": "User.paste"
|
||
},
|
||
{
|
||
"command":
|
||
{
|
||
"action": "newTab"
|
||
},
|
||
"id": "User.newTab.5DEADB41"
|
||
},
|
||
{
|
||
"command": "find",
|
||
"id": "User.find"
|
||
},
|
||
{
|
||
"command": "toggleFullscreen",
|
||
"id": "User.toggleFullscreen"
|
||
},
|
||
{
|
||
"command":
|
||
{
|
||
"action": "splitPane",
|
||
"split": "auto",
|
||
"splitMode": "duplicate"
|
||
},
|
||
"id": "User.splitPane.A6751878"
|
||
},
|
||
{
|
||
"command": "closePane",
|
||
"id": "User.closePane"
|
||
},
|
||
{
|
||
"command":
|
||
{
|
||
"action": "nextTab"
|
||
},
|
||
"id": "User.nextTab.0"
|
||
}
|
||
],
|
||
"copyFormatting": "none",
|
||
"copyOnSelect": false,
|
||
"defaultProfile": "{00000000-0000-0000-ba54-000000000002}",
|
||
"initialCols": 160,
|
||
"initialPosition": "50,420",
|
||
"initialRows": 30,
|
||
"keybindings":
|
||
[
|
||
{
|
||
"id": "User.copy.644BA8F2",
|
||
"keys": "ctrl+c"
|
||
},
|
||
{
|
||
"id": "User.newTab.5DEADB41",
|
||
"keys": "ctrl+t"
|
||
},
|
||
{
|
||
"id": "User.prevTab.0",
|
||
"keys": "ctrl+pgup"
|
||
},
|
||
{
|
||
"id": "User.splitPane.D5151347",
|
||
"keys": "ctrl+shift+\\"
|
||
},
|
||
{
|
||
"id": "User.splitPane.864CD510",
|
||
"keys": "ctrl+\\"
|
||
},
|
||
{
|
||
"id": "User.splitPane.A6751878",
|
||
"keys": "alt+shift+d"
|
||
},
|
||
{
|
||
"id": "User.find",
|
||
"keys": "ctrl+shift+f"
|
||
},
|
||
{
|
||
"id": "User.paste",
|
||
"keys": "ctrl+v"
|
||
},
|
||
{
|
||
"id": "User.toggleFullscreen",
|
||
"keys": "alt+x"
|
||
},
|
||
{
|
||
"id": "User.closePane",
|
||
"keys": "ctrl+w"
|
||
},
|
||
{
|
||
"id": "User.nextTab.0",
|
||
"keys": "ctrl+pgdn"
|
||
}
|
||
],
|
||
"newTabMenu":
|
||
[
|
||
{
|
||
"type": "remainingProfiles"
|
||
}
|
||
],
|
||
"profiles":
|
||
{
|
||
"defaults": {},
|
||
"list":
|
||
[
|
||
{
|
||
"colorScheme": "Dark+",
|
||
"commandline": "\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\" -NoLogo",
|
||
"font":
|
||
{
|
||
"face": "FiraCode Nerd Font"
|
||
},
|
||
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
|
||
"hidden": false,
|
||
"name": "Windows PowerShell"
|
||
},
|
||
{
|
||
"colorScheme": "One Half Dark",
|
||
"commandline": "\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\" -NoLogo",
|
||
"elevate": true,
|
||
"font":
|
||
{
|
||
"face": "FiraCode Nerd Font Mono"
|
||
},
|
||
"guid": "{41dd7a51-f0e1-4420-a2ec-1a7130b7e950}",
|
||
"hidden": false,
|
||
"icon": "%userprofile%/OneDrive/\u5716\u7247/icon/console_red.png",
|
||
"name": "Windows PowerShell(Administrator)"
|
||
},
|
||
{
|
||
"colorScheme": "Campbell",
|
||
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
|
||
"hidden": false,
|
||
"name": "Command Prompt"
|
||
},
|
||
{
|
||
"commandline": "%PROGRAMFILES%/git/usr/bin/bash.exe -i -l",
|
||
"font":
|
||
{
|
||
"face": "CaskaydiaCove Nerd Font Mono",
|
||
"size": 11
|
||
},
|
||
"guid": "{00000000-0000-0000-ba54-000000000002}",
|
||
"historySize": 32767,
|
||
"icon": "%PROGRAMFILES%/Git/mingw64/share/git/git-for-windows.ico",
|
||
"name": "Bash",
|
||
"startingDirectory": "%SYNODRIVE_PATH%/codes"
|
||
},
|
||
{
|
||
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
|
||
"hidden": false,
|
||
"name": "PowerShell",
|
||
"source": "Windows.Terminal.PowershellCore"
|
||
}
|
||
]
|
||
},
|
||
"schemes": [],
|
||
"tabWidthMode": "titleLength",
|
||
"themes": [],
|
||
"useAcrylicInTabRow": true
|
||
}
|
||
```
|
||
|
||
## Settings.json of MSIVECTOR16
|
||
```json
|
||
{
|
||
"$help": "https://aka.ms/terminal-documentation",
|
||
"$schema": "https://aka.ms/terminal-profiles-schema",
|
||
"actions":
|
||
[
|
||
{
|
||
"command":
|
||
{
|
||
"action": "copy",
|
||
"singleLine": false
|
||
},
|
||
"id": "User.copy.644BA8F2"
|
||
},
|
||
{
|
||
"command":
|
||
{
|
||
"action": "splitPane",
|
||
"split": "down"
|
||
},
|
||
"id": "User.splitPane.D5151347"
|
||
},
|
||
{
|
||
"command":
|
||
{
|
||
"action": "prevTab"
|
||
},
|
||
"id": "User.prevTab.0"
|
||
},
|
||
{
|
||
"command":
|
||
{
|
||
"action": "splitPane",
|
||
"split": "right"
|
||
},
|
||
"id": "User.splitPane.864CD510"
|
||
},
|
||
{
|
||
"command": "paste",
|
||
"id": "User.paste"
|
||
},
|
||
{
|
||
"command":
|
||
{
|
||
"action": "newTab"
|
||
},
|
||
"id": "User.newTab.5DEADB41"
|
||
},
|
||
{
|
||
"command": "toggleFullscreen",
|
||
"id": "User.toggleFullscreen"
|
||
},
|
||
{
|
||
"command": "find",
|
||
"id": "User.find"
|
||
},
|
||
{
|
||
"command":
|
||
{
|
||
"action": "splitPane",
|
||
"split": "auto",
|
||
"splitMode": "duplicate"
|
||
},
|
||
"id": "User.splitPane.A6751878"
|
||
},
|
||
{
|
||
"command": "closePane",
|
||
"id": "User.closePane"
|
||
},
|
||
{
|
||
"command":
|
||
{
|
||
"action": "nextTab"
|
||
},
|
||
"id": "User.nextTab.0"
|
||
}
|
||
],
|
||
"copyFormatting": "none",
|
||
"copyOnSelect": false,
|
||
"defaultProfile": "{00000000-0000-0000-ba54-000000000002}",
|
||
"initialCols": 160,
|
||
"initialPosition": "50,420",
|
||
"initialRows": 30,
|
||
"keybindings":
|
||
[
|
||
{
|
||
"id": "User.newTab.5DEADB41",
|
||
"keys": "ctrl+t"
|
||
},
|
||
{
|
||
"id": "User.copy.644BA8F2",
|
||
"keys": "ctrl+c"
|
||
},
|
||
{
|
||
"id": "User.prevTab.0",
|
||
"keys": "ctrl+pgup"
|
||
},
|
||
{
|
||
"id": "User.splitPane.D5151347",
|
||
"keys": "ctrl+shift+\\"
|
||
},
|
||
{
|
||
"id": "User.splitPane.A6751878",
|
||
"keys": "alt+shift+d"
|
||
},
|
||
{
|
||
"id": "User.splitPane.864CD510",
|
||
"keys": "ctrl+\\"
|
||
},
|
||
{
|
||
"id": "User.find",
|
||
"keys": "ctrl+shift+f"
|
||
},
|
||
{
|
||
"id": "User.paste",
|
||
"keys": "ctrl+v"
|
||
},
|
||
{
|
||
"id": "User.toggleFullscreen",
|
||
"keys": "alt+x"
|
||
},
|
||
{
|
||
"id": "User.closePane",
|
||
"keys": "ctrl+w"
|
||
},
|
||
{
|
||
"id": "User.nextTab.0",
|
||
"keys": "ctrl+pgdn"
|
||
}
|
||
],
|
||
"newTabMenu":
|
||
[
|
||
{
|
||
"type": "remainingProfiles"
|
||
}
|
||
],
|
||
"profiles":
|
||
{
|
||
"defaults": {},
|
||
"list":
|
||
[
|
||
{
|
||
"colorScheme": "Dark+",
|
||
"commandline": "\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\" -NoLogo",
|
||
"font":
|
||
{
|
||
"face": "FiraCode Nerd Font"
|
||
},
|
||
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
|
||
"hidden": false,
|
||
"name": "Windows PowerShell"
|
||
},
|
||
{
|
||
"colorScheme": "One Half Dark",
|
||
"commandline": "\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\" -NoLogo",
|
||
"elevate": true,
|
||
"font":
|
||
{
|
||
"face": "FiraCode Nerd Font Mono"
|
||
},
|
||
"guid": "{41dd7a51-f0e1-4420-a2ec-1a7130b7e950}",
|
||
"hidden": false,
|
||
"icon": "%userprofile%/OneDrive/\u5716\u7247/icon/console_red.png",
|
||
"name": "Windows PowerShell(Administrator)"
|
||
},
|
||
{
|
||
"colorScheme": "Campbell",
|
||
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
|
||
"hidden": false,
|
||
"name": "Command Prompt"
|
||
},
|
||
{
|
||
"commandline": "%PROGRAMFILES%/git/usr/bin/bash.exe -i -l",
|
||
"font":
|
||
{
|
||
"face": "CaskaydiaCove Nerd Font Mono",
|
||
"size": 11
|
||
},
|
||
"guid": "{00000000-0000-0000-ba54-000000000002}",
|
||
"historySize": 32767,
|
||
"icon": "%PROGRAMFILES%/Git/mingw64/share/git/git-for-windows.ico",
|
||
"name": "Bash",
|
||
"startingDirectory": "%SYNODRIVE_PATH%/codes"
|
||
},
|
||
{
|
||
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
|
||
"hidden": false,
|
||
"name": "PowerShell",
|
||
"source": "Windows.Terminal.PowershellCore"
|
||
},
|
||
{
|
||
"guid": "{09c82543-7f96-5d6d-8c03-d00abe359a3a}",
|
||
"hidden": false,
|
||
"name": "Developer Command Prompt for VS 2022",
|
||
"source": "Windows.Terminal.VisualStudio"
|
||
},
|
||
{
|
||
"guid": "{f048bdac-774a-59ae-ab49-4791c9155743}",
|
||
"hidden": false,
|
||
"name": "Developer PowerShell for VS 2022",
|
||
"source": "Windows.Terminal.VisualStudio"
|
||
}
|
||
]
|
||
},
|
||
"schemes": [],
|
||
"tabWidthMode": "titleLength",
|
||
"themes": [],
|
||
"useAcrylicInTabRow": true
|
||
}
|
||
```
|
||
|
||
## 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)
|