Última atividade 1 month ago

vscode 开发必选扩展

Revisão f1261ee809778e8d210fea9c0f7cea4046b903f9

README.md Bruto

VS Code 扩展推荐

扩展列表

名称 扩展 ID 链接 描述
Even Better TOML tamasfe.even-better-toml VSCode - OpenVSX 功能齐全的 TOML 支持
Choose a License ultram4rine.vscode-choosealicense VSCode - OpenVSX 为你的项目选择一个许可证
gitignore codezombiech.gitignore VSCode - OpenVSX https://github.com/github/gitignore 仓库拉取 .gitignore 模板。支持.gitignore 文件的语言。
index.txt Bruto
1tamasfe.even-better-toml
2ultram4rine.vscode-choosealicense
3codezombiech.gitignore
4
install Bruto
1#!/usr/bin/env bash
2
3BASE_URL="https://gist.asfd.cn/jetsung/vscode/raw/HEAD/"
4DESC_FILE="README.md"
5IDE_CMD="code"
6FORCE=false
7EXTRA=""
8VERBOSE=false
9
10# 参数解析
11parameters() {
12 while getopts "s:f e:n:v" opt; do
13 case $opt in
14 s) IDE_CMD="$OPTARG" ;;
15 f) FORCE=true ;;
16 e) EXTRA="$OPTARG" ;;
17 n) DESC_FILE="$OPTARG" ;; # -n now sets the README/md file
18 v) VERBOSE=true ;;
19 \?) echo "无效参数: -$OPTARG" >&2; exit 1 ;;
20 esac
21 done
22 shift $((OPTIND-1))
23 EXTRA="$EXTRA $@"
24}
25
26# 从 README.md 提取扩展 ID 列表(仅官方扩展 ID)
27extract_extensions() {
28 local content
29 if [[ "$DESC_FILE" == http* ]]; then
30 content=$(curl -s --fail "$DESC_FILE")
31 elif [[ -f "$DESC_FILE" ]]; then
32 content=$(cat "$DESC_FILE")
33 else
34 content=$(curl -s --fail "${BASE_URL}${DESC_FILE}")
35 fi
36
37 if [ $? -ne 0 ] || [ -z "$content" ]; then
38 echo "错误:无法加载 README 文件($DESC_FILE)" >&2
39 exit 1
40 fi
41
42 echo "$content" | awk '
43 BEGIN {
44 in_table = 0
45 }
46 /^\|/ && /名称.*扩展 ID/ {
47 in_table = 1
48 next
49 }
50 in_table && /^\|[-| ]+$/ { next } # 跳过分隔行
51 in_table && /^\|/ {
52 gsub(/^\|/, "", $0)
53 gsub(/\|$/, "", $0)
54 split($0, fields, " \\| ")
55 if (length(fields) >= 3) {
56 id = fields[2] # "扩展 ID" 是第二列(fields[1] 是名称)
57 gsub(/^[ \t]*`?/, "", id)
58 gsub(/`?[ \t]*$/, "", id)
59 if (id != "" && id != "-") {
60 print id
61 }
62 }
63 }
64 /^$/ { in_table = 0 } # 表格结束
65 '
66}
67
68# 显示详细信息(-v 模式)
69show_verbose() {
70 local content
71 if [[ "$DESC_FILE" == http* ]]; then
72 content=$(curl -s --fail "$DESC_FILE")
73 elif [[ -f "$DESC_FILE" ]]; then
74 content=$(cat "$DESC_FILE")
75 else
76 content=$(curl -s --fail "${BASE_URL}${DESC_FILE}")
77 fi
78
79 echo
80 echo "$content" | awk '
81 BEGIN {
82 in_table = 0
83 }
84 /^\|/ && /名称.*扩展 ID/ {
85 in_table = 1
86 next
87 }
88 in_table && /^\|[-| ]+$/ { next }
89 in_table && /^\|/ {
90 gsub(/^\|/, "", $0)
91 gsub(/\|$/, "", $0)
92 split($0, fields, " \\| ")
93 if (length(fields) >= 4) {
94 name_raw = fields[1]
95 id = fields[2]
96 desc = fields[4]
97
98 # 提取 **...** 中的名称
99 if (match(name_raw, /\*\*([^*]+)\*\*/)) {
100 name = substr(name_raw, RSTART+2, RLENGTH-4)
101 } else {
102 gsub(/[\[\]\*\`]/, "", name_raw)
103 name = name_raw
104 }
105
106 gsub(/^[ \t]*`?/, "", id)
107 gsub(/`?[ \t]*$/, "", id)
108 gsub(/^[ \t]+|[ \t]+$/, "", desc)
109
110 if (id != "" && id != "-") {
111 printf "名称: %s\n扩展ID: %s\n描述: %s\n\n", name, id, desc
112 }
113 }
114 }
115 /^$/ { in_table = 0 }
116 '
117 echo
118}
119
120# 主函数
121main() {
122 parameters "$@"
123
124 if $VERBOSE; then
125 show_verbose
126 exit 0
127 fi
128
129 echo "正在从 $DESC_FILE 提取扩展列表..."
130 EXTENSIONS=$(extract_extensions)
131
132 if [ -z "$EXTENSIONS" ]; then
133 echo "错误:未找到有效的扩展 ID 列表!" >&2
134 exit 1
135 fi
136
137 BASE_CMD="$IDE_CMD --install-extension"
138 if $FORCE; then
139 EXTRA="--force $EXTRA"
140 fi
141
142 echo "开始为 $IDE_CMD 安装扩展(命令: $BASE_CMD ... $EXTRA)"
143 echo "扩展列表:"
144 echo "$EXTENSIONS"
145 echo "-----------------"
146
147 while IFS= read -r ext; do
148 [ -z "$ext" ] && continue
149 echo "安装: $ext"
150 $BASE_CMD "$ext" $EXTRA || echo "警告: 安装 $ext 失败(可能已安装或 ID 无效)"
151 done <<< "$EXTENSIONS"
152
153 echo "-----------------"
154 echo "所有扩展安装完成!请重启 IDE 以生效。"
155}
156
157main "$@"
python.txt Bruto
1ms-python.isort
2ms-python.autopep8
3ms-python.python
4ms-python.vscode-pylance
5ms-python.vscode-python-envs
6ms-python.debugpy
7charliermarsh.ruff
8