vault backup: 2025-08-20 14:35:48
Affected files: Too many files to list
This commit is contained in:
304
22.01. 軟體工具、設定/Visual Studio Code.md
Normal file
304
22.01. 軟體工具、設定/Visual Studio Code.md
Normal file
@@ -0,0 +1,304 @@
|
||||
# 快速鍵
|
||||
## 顯示快速鍵列表
|
||||
- Windows: `Ctrl + k` + `Ctrl + s`
|
||||
- Mac: `⌘ + k` + `⌘ + s`
|
||||
|
||||
## 分割目前視窗
|
||||
- Windows: `Ctrl + \`
|
||||
- Mac: `⌘ + \`
|
||||
|
||||
## 程式格式化
|
||||
### 格式化整個文件
|
||||
`Shift + Alf + f`
|
||||
|
||||
### 格式化選取的範圍
|
||||
`Ctrl + k` + `Ctrl + f`
|
||||
|
||||
### setting.json
|
||||
- `"editor.formatOnType": true`:輸入一行後,自動格式化目前這一行。
|
||||
- `"editor.formatOnSave": true`:儲存時格式化檔案。
|
||||
- `"editor.formatOnPaste": true`:貼上程式碼時格式化貼上的內容。
|
||||
|
||||
```json
|
||||
{
|
||||
// 文字編輯器
|
||||
"editor.bracketPairColorization.enabled": true,
|
||||
"editor.fontFamily": "Cascadia Code", // 字型
|
||||
"editor.fontLigatures": true, //啟用連字
|
||||
"editor.fontSize": 14, // 文字大小
|
||||
"editor.fontWeight": "normal",
|
||||
"editor.guides.bracketPairs": false,
|
||||
"editor.guides.indentation": false,
|
||||
"editor.insertSpaces": true,
|
||||
"editor.minimap.renderCharacters": false,
|
||||
"editor.renderWhitespace": "boundary",
|
||||
"editor.renderLineHighlight": "all", // 整行高亮
|
||||
"editor.snippetSuggestions": "top", // 將程式碼片段建議顯示於頂端
|
||||
"editor.tabCompletion": "on", // 啟用tab鍵自動完成
|
||||
"editor.tabSize": 4,
|
||||
"editor.wordWrap": "off",
|
||||
|
||||
// 檔案
|
||||
"files.trimTrailingWhitespace": true, // 儲存檔案時去除行尾空白
|
||||
"files.insertFinalNewline": true, // 儲存檔案時在結尾插入一個新行
|
||||
|
||||
// 檔案管理員
|
||||
"explorer.confirmDelete": false,
|
||||
|
||||
// 工作台
|
||||
"workbench.colorTheme": "One Dark Pro", // 主題
|
||||
"workbench.iconTheme": "material-icon-theme", // Icon主題
|
||||
"workbench.tree.indent": 15,
|
||||
"workbench.tree.renderIndentGuides": "always",
|
||||
"workbench.colorCustomizations": {
|
||||
"tree.indentGuidesStroke": "#05ef3c"
|
||||
},
|
||||
"breadcrumbs.enabled": true, // 啟用麵包屑,可以通過上方路徑來資料夾、文件或者是函數的跳轉
|
||||
"oneDarkPro.vivid": true,
|
||||
"diffEditor.wordWrap": "off",
|
||||
|
||||
// 終端機
|
||||
"terminal.integrated.fontFamily": "Fira Code",
|
||||
"editor.accessibilitySupport": "off",
|
||||
"[python]": {
|
||||
"editor.formatOnType": true
|
||||
},
|
||||
"polacode.target": "snippet",
|
||||
"editor.inlineSuggest.enabled": true,
|
||||
"github.copilot.enable": {
|
||||
"*": true,
|
||||
"yaml": false,
|
||||
"plaintext": false,
|
||||
"markdown": false,
|
||||
"scminput": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 折疊程式碼
|
||||
### 收起目前區塊
|
||||
- Windows: `Ctrl + Shift + [`
|
||||
- Mac: `⌥ + ⌘ + [`
|
||||
|
||||
### 打開目前區塊
|
||||
- Windows: `Ctrl + Shift + ]`
|
||||
- Mac: `⌥ + ⌘ + ]`
|
||||
|
||||
### 收起目前區塊(整個檔案)
|
||||
- Windows: `Ctrl + (K => 0) (zero)`
|
||||
- Mac: `⌘ + (K => 0) (zero)`
|
||||
|
||||
### 打開目前區塊(整個檔案)
|
||||
- Windows: `Ctrl + (K => J) `
|
||||
- Mac: `⌘ + (K => J)`
|
||||
|
||||
## 在「已開啟的檔案」間跳轉
|
||||
`Ctrl + tab`
|
||||
|
||||
# Plugin
|
||||
## Setting Sync
|
||||
- 參考:[https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync](https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync)
|
||||
~~- GIST Token: `e0f7c5233e3c6dafee77047f61ea74f0d01d24e1`~~
|
||||
- GIST Token: `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`
|
||||
- GIST ID: [`aaee0ee8733879ef2da2eb1b4bf8a993`](https://gist.github.com/AwinHuang/aaee0ee8733879ef2da2eb1b4bf8a993)
|
||||
- GIST address: [https://gist.github.com/AwinHuang/aaee0ee8733879ef2da2eb1b4bf8a993](https://gist.github.com/AwinHuang/aaee0ee8733879ef2da2eb1b4bf8a993)
|
||||
|
||||
# Code snippets
|
||||
## html.json
|
||||
```json
|
||||
{
|
||||
"HTML template": {
|
||||
"prefix": "HTML_template",
|
||||
"body": [
|
||||
"<!doctype html>",
|
||||
"",
|
||||
"<html lang=\"en\">",
|
||||
"<head>",
|
||||
" <meta charset=\"utf-8\">",
|
||||
" <meta name=\"description\" content=\"Awin's HTML template\">",
|
||||
" <meta name=\"author\" content=\"Awin Huang\">",
|
||||
" <script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js\"></script>",
|
||||
" <title>A HTML template</title>",
|
||||
"</head>",
|
||||
"",
|
||||
"<body>",
|
||||
" <H1>Awin's HTML template</H1>",
|
||||
" <p>Click to hide</p>",
|
||||
"</body>",
|
||||
"</html>",
|
||||
"",
|
||||
"<script>",
|
||||
" $(document).ready(function(){",
|
||||
" $(\"p\").click(function(){",
|
||||
" $(this).hide();",
|
||||
" });",
|
||||
" });",
|
||||
"</script>",
|
||||
],
|
||||
"description": "HTML template"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## python.json
|
||||
```json
|
||||
{
|
||||
"Python template": {
|
||||
"prefix": "Python_Template",
|
||||
"body": [
|
||||
"import sys",
|
||||
"import argparse",
|
||||
"",
|
||||
"",
|
||||
"def main(args=None):",
|
||||
" ${1:pass}",
|
||||
"",
|
||||
"",
|
||||
"if __name__ == '__main__':",
|
||||
" parser = argparse.ArgumentParser()",
|
||||
" parser.add_argument(\"first_file\", help=\"The first file\")",
|
||||
" parser.add_argument(\"-s\", \"--sample_args\", default=\"sample_args\", help=\"Modify this arguments for you\")",
|
||||
" args = parser.parse_args()",
|
||||
" main(args)",
|
||||
" sys.exit(0)"
|
||||
],
|
||||
"description": "Python script template"
|
||||
},
|
||||
|
||||
"F Print": {
|
||||
"prefix": "f-print",
|
||||
"body": [
|
||||
"print(f'$1 = {$1}')"
|
||||
],
|
||||
"description": "print() with f-string and default {}"
|
||||
},
|
||||
"Q Print": {
|
||||
"prefix": "q-print",
|
||||
"body": [
|
||||
"print('$1 = {}, '.format($1))"
|
||||
],
|
||||
"description": "print() with f-string and default {}"
|
||||
},
|
||||
"Debug RobotRun": {
|
||||
"prefix": "debug_robotrun",
|
||||
"body": [
|
||||
"import os",
|
||||
"import sys",
|
||||
"sys.path.insert(0, 'D:/codes/logitech/')",
|
||||
"import RobotRun",
|
||||
"print('+------------------------------------------------------------------------------+')",
|
||||
"print('| |')",
|
||||
"print('| RobotRun: {}'.format(RobotRun.__file__))",
|
||||
"print('| |')",
|
||||
"print('+------------------------------------------------------------------------------+')",
|
||||
],
|
||||
"description": "Change RobotRun to local version"
|
||||
},
|
||||
"Flask template": {
|
||||
"prefix": "Flask_Template",
|
||||
"body": [
|
||||
"## Flask template",
|
||||
"## Author: Awin Huang",
|
||||
"## Date: 2020/04/09",
|
||||
"",
|
||||
"import os, sys",
|
||||
"import datetime",
|
||||
"import json",
|
||||
"from flask import Flask, render_template, request",
|
||||
"",
|
||||
"",
|
||||
"app = Flask(__name__)",
|
||||
"",
|
||||
"## Setup log",
|
||||
"handler = logging.FileHandler('flask.log', delay=False)",
|
||||
"handler.setLevel(logging.INFO)",
|
||||
"app.logger.addHandler(handler)",
|
||||
"app.logger.setLevel(logging.INFO)",
|
||||
"",
|
||||
"",
|
||||
"def info_log(msg):",
|
||||
" app.logger.info(msg)",
|
||||
" # print(msg)",
|
||||
"",
|
||||
"",
|
||||
"def error_log(msg):",
|
||||
" app.logger.error(msg)",
|
||||
"",
|
||||
"",
|
||||
"@app.route('/')",
|
||||
"def index():",
|
||||
" info_log('Return main page to user.')",
|
||||
" return 'Hello, this is main page'",
|
||||
"",
|
||||
"",
|
||||
"## Receive a GET request",
|
||||
"@app.route('/get_get', methods=['GET'])",
|
||||
"def run_testcase():",
|
||||
" command = request.args.get('command')",
|
||||
" value = 'This is value for GET'",
|
||||
" return {",
|
||||
" 'command': command,",
|
||||
" 'value': value",
|
||||
" }",
|
||||
"",
|
||||
"",
|
||||
"## Receive a POST request",
|
||||
"@app.route('/get_post', methods=['POST'])",
|
||||
"def get_post():",
|
||||
" command = request.form['command']",
|
||||
" value = 'This is value for POST'",
|
||||
" return {",
|
||||
" 'command': command:",
|
||||
" 'value': value",
|
||||
" }",
|
||||
"",
|
||||
"",
|
||||
"if __name__ == '__main__':",
|
||||
" app.debug = True",
|
||||
" app.run(host='0.0.0.0')",
|
||||
],
|
||||
"description": "Flask template"
|
||||
},
|
||||
"Datetime now": {
|
||||
"prefix": "now_dt",
|
||||
"body": [
|
||||
"datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S:%f')"
|
||||
],
|
||||
"description": "Get datetime.now() with format '%Y-%m-%d %H:%M:%S:%f'"
|
||||
},
|
||||
"Run process": {
|
||||
"prefix": "runprocess",
|
||||
"body": [
|
||||
"import multiprocessing as mp",
|
||||
"",
|
||||
"process = mp.Process(target=task_set.run, args=(self.task_sync, args))",
|
||||
"process.start()",
|
||||
"process.join()"
|
||||
],
|
||||
"description": "Run function in a process"
|
||||
},
|
||||
"Sleep with dots": {
|
||||
"prefix": "sleepdots",
|
||||
"body": [
|
||||
"for i in range($1):",
|
||||
" import time",
|
||||
" print(\".\", end=\"\", flush=True)",
|
||||
" time.sleep(1)",
|
||||
],
|
||||
"description": "Sleep and print \".\" every second"
|
||||
},
|
||||
"Sleep with numbers": {
|
||||
"prefix": "sleepnum",
|
||||
"body": [
|
||||
"for i in range($1):",
|
||||
" print(f\"{i+1} \", end=\"\", flush=True)",
|
||||
" time.sleep(1)",
|
||||
],
|
||||
"description": "Sleep and print number every second"
|
||||
},
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## 參考
|
||||
- [VSCode 是什么](https://geek-docs.com/vscode/vscode-tutorials/what-is-vscode.html)
|
||||
258
22.01. 軟體工具、設定/Windows Terminal-Awin的MacBook Pro.md
Normal file
258
22.01. 軟體工具、設定/Windows Terminal-Awin的MacBook Pro.md
Normal file
@@ -0,0 +1,258 @@
|
||||
## 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": "right"
|
||||
},
|
||||
"id": "User.splitPane.864CD510"
|
||||
},
|
||||
{
|
||||
"command":
|
||||
{
|
||||
"action": "splitPane",
|
||||
"split": "down"
|
||||
},
|
||||
"id": "User.splitPane.D5151347"
|
||||
},
|
||||
{
|
||||
"command":
|
||||
{
|
||||
"action": "copy",
|
||||
"singleLine": false
|
||||
},
|
||||
"id": "User.copy.644BA8F2"
|
||||
},
|
||||
{
|
||||
"command": "find",
|
||||
"id": "User.find"
|
||||
},
|
||||
{
|
||||
"command": "toggleFullscreen",
|
||||
"id": "User.toggleFullscreen"
|
||||
},
|
||||
{
|
||||
"command":
|
||||
{
|
||||
"action": "splitPane",
|
||||
"split": "auto",
|
||||
"splitMode": "duplicate"
|
||||
},
|
||||
"id": "User.splitPane.A6751878"
|
||||
},
|
||||
{
|
||||
"command":
|
||||
{
|
||||
"action": "newTab"
|
||||
},
|
||||
"id": "User.newTab.5DEADB41"
|
||||
},
|
||||
{
|
||||
"command": "paste",
|
||||
"id": "User.paste"
|
||||
},
|
||||
{
|
||||
"command":
|
||||
{
|
||||
"action": "prevTab"
|
||||
},
|
||||
"id": "User.prevTab.0"
|
||||
},
|
||||
{
|
||||
"command": "closePane",
|
||||
"id": "User.closePane"
|
||||
},
|
||||
{
|
||||
"command":
|
||||
{
|
||||
"action": "nextTab"
|
||||
},
|
||||
"id": "User.nextTab.0"
|
||||
}
|
||||
],
|
||||
"copyFormatting": "none",
|
||||
"copyOnSelect": false,
|
||||
"defaultProfile": "{00000000-0000-0000-ba54-000000000002}",
|
||||
"initialCols": 230,
|
||||
"initialPosition": "50,900",
|
||||
"initialRows": 30,
|
||||
"keybindings":
|
||||
[
|
||||
{
|
||||
"id": "User.splitPane.864CD510",
|
||||
"keys": "ctrl+shift+e"
|
||||
},
|
||||
{
|
||||
"id": "User.splitPane.D5151347",
|
||||
"keys": "ctrl+shift+o"
|
||||
},
|
||||
{
|
||||
"id": "User.newTab.5DEADB41",
|
||||
"keys": "ctrl+t"
|
||||
},
|
||||
{
|
||||
"id": "User.copy.644BA8F2",
|
||||
"keys": "ctrl+c"
|
||||
},
|
||||
{
|
||||
"id": "User.splitPane.A6751878",
|
||||
"keys": "alt+shift+d"
|
||||
},
|
||||
{
|
||||
"id": "User.paste",
|
||||
"keys": "ctrl+v"
|
||||
},
|
||||
{
|
||||
"id": "User.find",
|
||||
"keys": "ctrl+shift+f"
|
||||
},
|
||||
{
|
||||
"id": "User.toggleFullscreen",
|
||||
"keys": "alt+x"
|
||||
},
|
||||
{
|
||||
"id": "User.prevTab.0",
|
||||
"keys": "ctrl+pgup"
|
||||
},
|
||||
{
|
||||
"id": "User.closePane",
|
||||
"keys": "ctrl+w"
|
||||
},
|
||||
{
|
||||
"id": "User.nextTab.0",
|
||||
"keys": "ctrl+pgdn"
|
||||
}
|
||||
],
|
||||
"newTabMenu":
|
||||
[
|
||||
{
|
||||
"type": "remainingProfiles"
|
||||
}
|
||||
],
|
||||
"profiles":
|
||||
{
|
||||
"defaults": {},
|
||||
"list":
|
||||
[
|
||||
{
|
||||
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
|
||||
"hidden": false,
|
||||
"name": "Windows PowerShell"
|
||||
},
|
||||
{
|
||||
"colorScheme": "Tango Dark",
|
||||
"commandline": "gsudo.exe powershell.exe",
|
||||
"font":
|
||||
{
|
||||
"face": "Fira Code"
|
||||
},
|
||||
"guid": "{41dd7a51-f0e1-4420-a2ec-1a7130b7e950}",
|
||||
"hidden": false,
|
||||
"icon": "%userprofile%/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 Nerd Font Mono",
|
||||
"size": 11
|
||||
},
|
||||
"guid": "{00000000-0000-0000-ba54-000000000002}",
|
||||
"historySize": 9000,
|
||||
"icon": "%PROGRAMFILES%/Git/mingw64/share/git/git-for-windows.ico",
|
||||
"name": "Bash",
|
||||
"startingDirectory": "%SYNODRIVE_PATH%/codes"
|
||||
},
|
||||
{
|
||||
"guid": "{ee3203b6-a810-5d69-a2fc-42a327122769}",
|
||||
"hidden": false,
|
||||
"name": "Developer Command Prompt for VS 2022",
|
||||
"source": "Windows.Terminal.VisualStudio"
|
||||
},
|
||||
{
|
||||
"guid": "{bf8c5b3b-1d1e-53ff-bb67-f2b3f5a6c4eb}",
|
||||
"hidden": false,
|
||||
"name": "Developer PowerShell for VS 2022",
|
||||
"source": "Windows.Terminal.VisualStudio"
|
||||
},
|
||||
{
|
||||
"guid": "{16208362-94fc-5b1f-a491-5b2624d5ab56}",
|
||||
"hidden": true,
|
||||
"name": "Visual Studio Debug Console",
|
||||
"source": "VSDebugConsole"
|
||||
}
|
||||
]
|
||||
},
|
||||
"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)
|
||||
Reference in New Issue
Block a user