Last active 1 month ago

vscode 开发必选扩展

jetsung revised this gist 5 months ago. Go to revision

1 file changed, 1 insertion

install

@@ -53,6 +53,7 @@ main() {
53 53 } else {
54 54 name = ""
55 55 }
56 + echo $name
56 57
57 58 # 重置 line 为原始
58 59 line = $0

jetsung revised this gist 5 months ago. Go to revision

1 file changed, 1 deletion

install

@@ -82,7 +82,6 @@ main() {
82 82 if (length(fields) >= 5) {
83 83 name_field = fields[2]
84 84 gsub(/^[ \t]+|[ \t]+$/, "", name_field)
85 - gsub(/\[\*\*[^*]+\*\*\]\[\d+\]/, "", name_field) # 去除链接部分,留空? 等下已提取name
86 85 # 用之前提取的 name
87 86
88 87 id_official_field = fields[3]

jetsung revised this gist 5 months ago. Go to revision

1 file changed, 1 insertion, 1 deletion

install

@@ -95,7 +95,7 @@ main() {
95 95 desc_field = fields[5]
96 96 gsub(/^[ \t]+|[ \t]+$/, "", desc_field)
97 97
98 - printf "名称:%s \n扩展ID:%s \n扩展ID:%s \n描述:%s\n\n", name, id_official_field, id_other_field, desc_field
98 + printf "名称: %s \n扩展ID: %s \n扩展ID: %s \n描述: %s\n\n", name, id_official_field, id_other_field, desc_field
99 99 }
100 100 }'
101 101 echo

jetsung revised this gist 5 months ago. Go to revision

1 file changed, 3 insertions, 1 deletion

install

@@ -36,6 +36,7 @@ main() {
36 36 URL_DESC="${BASE_URL}${DESC_FILE}"
37 37
38 38 if $VERBOSE; then
39 + echo
39 40 # -v 模式:下载 README.md,先提取表格数据行(跳过标题和分隔行),然后逐行处理输出纯文本格式
40 41 curl -s --fail "$URL_DESC" | awk '
41 42 # 只处理数据行:以 "| [**" 开头(名称带链接)
@@ -94,9 +95,10 @@ main() {
94 95 desc_field = fields[5]
95 96 gsub(/^[ \t]+|[ \t]+$/, "", desc_field)
96 97
97 - printf "名称:%s \n扩展ID:%s \n扩展ID:%s \n描述:%s\n", name, id_official_field, id_other_field, desc_field
98 + printf "名称:%s \n扩展ID:%s \n扩展ID:%s \n描述:%s\n\n", name, id_official_field, id_other_field, desc_field
98 99 }
99 100 }'
101 + echo
100 102 exit 0
101 103 fi
102 104

jetsung revised this gist 5 months ago. Go to revision

1 file changed, 56 insertions, 21 deletions

install

@@ -6,7 +6,7 @@ DESC_FILE="README.md" # 描述 Markdown 文件
6 6 IDE_CMD="code" # 默认 VSCode
7 7 FORCE=false
8 8 EXTRA=""
9 - VERBOSE=false # -v: 只显示详细扩展信息(分块格式),不安装
9 + VERBOSE=false # -v: 只显示详细扩展信息(纯文本单行格式),不安装
10 10
11 11 # 参数解析函数
12 12 parameters() {
@@ -29,38 +29,73 @@ main() {
29 29 parameters "$@"
30 30
31 31 # 处理 LIST_FILE
32 - if [[ "$LIST_FILE" != "*.*" ]] && [[ "$LIST_FILE" != "*.*" ]]; then
32 + if [[ "$LIST_FILE" != "*.*" ]] && [[ "$LIST_FILE" != *.* ]]; then
33 33 LIST_FILE="${LIST_FILE}.txt"
34 34 fi
35 35
36 36 URL_DESC="${BASE_URL}${DESC_FILE}"
37 37
38 38 if $VERBOSE; then
39 - # -v 模式:下载 README.md,提取每个扩展的信息,按分块格式输出(每个扩展一组,空行分隔)
40 - echo "" # 开头空一行
39 + # -v 模式:下载 README.md,先提取表格数据行(跳过标题和分隔行),然后逐行处理输出纯文本格式
41 40 curl -s --fail "$URL_DESC" | awk '
42 - /^\| \[\*\*[^*]+\*\*\]\[\d+\] \| `/ {
43 - # 用 split 分隔 |
41 + # 只处理数据行:以 "| [**" 开头(名称带链接)
42 + /^\| \[\*\*/ {
43 + line = $0
44 +
45 + # 提取名称:去除 [**name**][n]
46 + if (match(line, /\[\*\*([^*]+)\*\*\]\[\d+\]/)) {
47 + name = substr(line, RSTART + 3, RLENGTH - 7 - length(match(line, /\[\d+\]/))) # 调整去除 [n]
48 + # 更精确:从 ** 后到 ** 前
49 + sub(/.*\[\*\*/, "", line)
50 + sub(/\*\*\].*/, "", line)
51 + name = line
52 + } else {
53 + name = ""
54 + }
55 +
56 + # 重置 line 为原始
57 + line = $0
58 +
59 + # 提取官方 ID:去除 `
60 + if (match(line, /`([^`]+)`/)) {
61 + id_official = substr(line, RSTART + 1, RLENGTH - 2)
62 + } else {
63 + id_official = ""
64 + }
65 +
66 + # 提取其他 ID:第三列,通常 -
67 + sub(/.*\| [^|]* \| [^|]* \| /, "", line) # 临时去除到第三列后
68 + if (match(line, /^ ([^ |]+) /)) {
69 + id_other = substr(line, RSTART + 1, RLENGTH - 2)
70 + } else {
71 + id_other = "-"
72 + }
73 +
74 + # 提取描述:第五列(最后一列)
75 + if (match($0, /\| ([^|]+) \| ([^|]+) \| ([^|]+) \| (.*) \|$/)) {
76 + desc = substr($0, RSTART + RLENGTH - length($4) - 1) # 复杂,改用 split
77 + }
78 +
79 + # 更可靠方式:用 split 分隔 |
44 80 split($0, fields, "|")
81 + if (length(fields) >= 5) {
82 + name_field = fields[2]
83 + gsub(/^[ \t]+|[ \t]+$/, "", name_field)
84 + gsub(/\[\*\*[^*]+\*\*\]\[\d+\]/, "", name_field) # 去除链接部分,留空? 等下已提取name
85 + # 用之前提取的 name
45 86
46 - # 名称:去除空格、链接和粗体
47 - name = fields[2]
48 - gsub(/^[ \t]+|[ \t]+$/, "", name)
49 - gsub(/\[\*\*[^*]+\*\*\]\[\d+\]/, "", name)
87 + id_official_field = fields[3]
88 + gsub(/^[ \t]+|[ \t]+$/, "", id_official_field)
89 + gsub(/`/, "", id_official_field)
50 90
51 - # 扩展 ID(官方):去除空格和 `
52 - id_official = fields[3]
53 - gsub(/^[ \t]+|[ \t]+$|`/, "", id_official)
91 + id_other_field = fields[4]
92 + gsub(/^[ \t]+|[ \t]+$/, "", id_other_field)
54 93
55 - # 描述:去除空格
56 - desc = fields[5]
57 - gsub(/^[ \t]+|[ \t]+$/, "", desc)
94 + desc_field = fields[5]
95 + gsub(/^[ \t]+|[ \t]+$/, "", desc_field)
58 96
59 - # 输出指定分块格式
60 - print "名称: " name
61 - print "扩展 ID: " id_official
62 - print "描述: " desc
63 - print "" # 每个扩展后空一行分隔
97 + printf "名称:%s \n扩展ID:%s \n扩展ID:%s \n描述:%s\n", name, id_official_field, id_other_field, desc_field
98 + }
64 99 }'
65 100 exit 0
66 101 fi

jetsung revised this gist 5 months ago. Go to revision

1 file changed, 7 insertions, 6 deletions

install

@@ -29,25 +29,26 @@ main() {
29 29 parameters "$@"
30 30
31 31 # 处理 LIST_FILE
32 - if [[ "$LIST_FILE" != "*.*" ]] && [[ "$LIST_FILE" != *.* ]]; then
32 + if [[ "$LIST_FILE" != "*.*" ]] && [[ "$LIST_FILE" != "*.*" ]]; then
33 33 LIST_FILE="${LIST_FILE}.txt"
34 34 fi
35 35
36 36 URL_DESC="${BASE_URL}${DESC_FILE}"
37 37
38 38 if $VERBOSE; then
39 - # -v 模式:下载 README.md,提取每个扩展的信息,按指定分块格式输出(每个扩展一组,空行分隔)
40 - echo "" # 开头空一行(可选,如果你不要可以删)
39 + # -v 模式:下载 README.md,提取每个扩展的信息,按分块格式输出(每个扩展一组,空行分隔)
40 + echo "" # 开头空一行
41 41 curl -s --fail "$URL_DESC" | awk '
42 42 /^\| \[\*\*[^*]+\*\*\]\[\d+\] \| `/ {
43 + # 用 split 分隔 |
43 44 split($0, fields, "|")
44 45
45 - # 名称:去除 Markdown 链接和粗体
46 + # 名称:去除空格、链接和粗体
46 47 name = fields[2]
47 48 gsub(/^[ \t]+|[ \t]+$/, "", name)
48 49 gsub(/\[\*\*[^*]+\*\*\]\[\d+\]/, "", name)
49 50
50 - # 扩展 ID(官方):去除 ` 和空格
51 + # 扩展 ID(官方):去除空格和 `
51 52 id_official = fields[3]
52 53 gsub(/^[ \t]+|[ \t]+$|`/, "", id_official)
53 54
@@ -55,7 +56,7 @@ main() {
55 56 desc = fields[5]
56 57 gsub(/^[ \t]+|[ \t]+$/, "", desc)
57 58
58 - # 输出指定格式
59 + # 输出指定分块格式
59 60 print "名称: " name
60 61 print "扩展 ID: " id_official
61 62 print "描述: " desc

jetsung revised this gist 5 months ago. Go to revision

1 file changed, 12 insertions, 17 deletions

install

@@ -6,7 +6,7 @@ DESC_FILE="README.md" # 描述 Markdown 文件
6 6 IDE_CMD="code" # 默认 VSCode
7 7 FORCE=false
8 8 EXTRA=""
9 - VERBOSE=false # -v: 只显示详细扩展信息(终端友好表格格式),不安装
9 + VERBOSE=false # -v: 只显示详细扩展信息(分块格式),不安装
10 10
11 11 # 参数解析函数
12 12 parameters() {
@@ -36,35 +36,30 @@ main() {
36 36 URL_DESC="${BASE_URL}${DESC_FILE}"
37 37
38 38 if $VERBOSE; then
39 - # -v 模式:下载 README.md,提取表格数据行,输出终端友好纯文本表格(带表头、分隔线)
40 - echo "" # 显示前空一行
39 + # -v 模式:下载 README.md,提取每个扩展的信息,按指定分块格式输出(每个扩展一组,空行分隔)
40 + echo "" # 开头空一行(可选,如果你不要可以删)
41 41 curl -s --fail "$URL_DESC" | awk '
42 - BEGIN {
43 - print "名称 扩展 ID (官方) 扩展 ID() 描述"
44 - print "-----------------------------------------------------------------------------------------------"
45 - }
46 - /^\| \[\*\*[^\]]+\]\[\d+\] \| `[^`]+` \| - \| / {
42 + /^\| \[\*\*[^*]+\*\*\]\[\d+\] \| `/ {
47 43 split($0, fields, "|")
48 44
49 - # 名称:去除空格和链接语法
45 + # 名称:去除 Markdown 链接和粗体
50 46 name = fields[2]
51 47 gsub(/^[ \t]+|[ \t]+$/, "", name)
52 - gsub(/\[\*\*[^\]]+\]\[\d+\]/, "", name)
48 + gsub(/\[\*\*[^*]+\*\*\]\[\d+\]/, "", name)
53 49
54 - # 官方 ID:去除空格和 `
50 + # 扩展 ID(官方):去除 ` 和空格
55 51 id_official = fields[3]
56 52 gsub(/^[ \t]+|[ \t]+$|`/, "", id_official)
57 53
58 - # 其他 ID:去除空格
59 - id_other = fields[4]
60 - gsub(/^[ \t]+|[ \t]+$/, "", id_other)
61 -
62 54 # 描述:去除空格
63 55 desc = fields[5]
64 56 gsub(/^[ \t]+|[ \t]+$/, "", desc)
65 57
66 - # 输出对齐行
67 - printf "%-30s %-35s %-12s %s\n", name, id_official, id_other, desc
58 + # 输出指定格式
59 + print "名称: " name
60 + print "扩展 ID: " id_official
61 + print "描述: " desc
62 + print "" # 每个扩展后空一行分隔
68 63 }'
69 64 exit 0
70 65 fi

jetsung revised this gist 5 months ago. Go to revision

1 file changed, 2 insertions, 2 deletions

install

@@ -43,10 +43,10 @@ main() {
43 43 print "名称 扩展 ID (官方) 扩展 ID() 描述"
44 44 print "-----------------------------------------------------------------------------------------------"
45 45 }
46 - /^\| \[\*\*[^\]]+\]\[\d+\] \| `[^`]+` \|/ {
46 + /^\| \[\*\*[^\]]+\]\[\d+\] \| `[^`]+` \| - \| / {
47 47 split($0, fields, "|")
48 48
49 - # 名称:去除空格、链接、粗体
49 + # 名称:去除空格和链接语法
50 50 name = fields[2]
51 51 gsub(/^[ \t]+|[ \t]+$/, "", name)
52 52 gsub(/\[\*\*[^\]]+\]\[\d+\]/, "", name)

jetsung revised this gist 5 months ago. Go to revision

1 file changed, 9 insertions, 11 deletions

install

@@ -36,37 +36,35 @@ main() {
36 36 URL_DESC="${BASE_URL}${DESC_FILE}"
37 37
38 38 if $VERBOSE; then
39 - # -v 模式:下载 README.md,提取扩展表格部分,转换为终端友好纯文本表格(带表头、分隔线)
39 + # -v 模式:下载 README.md,提取表格数据行,输出终端友好纯文本表格(带表头、分隔线)
40 40 echo "" # 显示前空一行
41 41 curl -s --fail "$URL_DESC" | awk '
42 42 BEGIN {
43 43 print "名称 扩展 ID (官方) 扩展 ID() 描述"
44 44 print "-----------------------------------------------------------------------------------------------"
45 45 }
46 - /^\| \[\*\*[^\]]+\]\[\d+\] \| `/ {
47 - # 用 split 分隔 |
46 + /^\| \[\*\*[^\]]+\]\[\d+\] \| `[^`]+` \|/ {
48 47 split($0, fields, "|")
49 48
50 - # 名称(去除 Markdown 链接和粗体)
49 + # 名称:去除空格、链接、粗体
51 50 name = fields[2]
52 51 gsub(/^[ \t]+|[ \t]+$/, "", name)
53 - gsub(/\[\*\*[^\*]+\*\*\]\[\d+\]/, "", name)
54 - gsub(/^\*\*|\*\*$/, "", name) # 万一残留
52 + gsub(/\[\*\*[^\]]+\]\[\d+\]/, "", name)
55 53
56 - # 官方 ID(去除 ` 和空格)
54 + # 官方 ID:去除空格和 `
57 55 id_official = fields[3]
58 56 gsub(/^[ \t]+|[ \t]+$|`/, "", id_official)
59 57
60 - # 其他 ID
58 + # 其他 ID:去除空格
61 59 id_other = fields[4]
62 60 gsub(/^[ \t]+|[ \t]+$/, "", id_other)
63 61
64 - # 描述
62 + # 描述:去除空格
65 63 desc = fields[5]
66 64 gsub(/^[ \t]+|[ \t]+$/, "", desc)
67 65
68 - # 格式化输出(固定宽度对齐)
69 - printf "%-30s %-35s %-10s %s\n", name, id_official, id_other, desc
66 + # 输出对齐行
67 + printf "%-30s %-35s %-12s %s\n", name, id_official, id_other, desc
70 68 }'
71 69 exit 0
72 70 fi

jetsung revised this gist 5 months ago. Go to revision

1 file changed, 26 insertions, 55 deletions

install

@@ -6,7 +6,7 @@ DESC_FILE="README.md" # 描述 Markdown 文件
6 6 IDE_CMD="code" # 默认 VSCode
7 7 FORCE=false
8 8 EXTRA=""
9 - VERBOSE=false # -v: 只显示详细扩展信息(纯文本单行格式),不安装
9 + VERBOSE=false # -v: 只显示详细扩展信息(终端友好表格格式),不安装
10 10
11 11 # 参数解析函数
12 12 parameters() {
@@ -36,66 +36,37 @@ main() {
36 36 URL_DESC="${BASE_URL}${DESC_FILE}"
37 37
38 38 if $VERBOSE; then
39 - # -v 模式:下载 README.md,先提取表格数据行(跳过标题和分隔行),然后逐行处理输出纯文本格式
39 + # -v 模式:下载 README.md,提取扩展表格部分,转换为终端友好纯文本表格(带表头、分隔线)
40 + echo "" # 显示前空一行
40 41 curl -s --fail "$URL_DESC" | awk '
41 - # 只处理数据行:以 "| [**" 开头(名称带链接)
42 - /^\| \[\*\*/ {
43 - line = $0
44 -
45 - # 提取名称:去除 [**name**][n]
46 - if (match(line, /\[\*\*([^*]+)\*\*\]\[\d+\]/)) {
47 - name = substr(line, RSTART + 3, RLENGTH - 7 - length(match(line, /\[\d+\]/))) # 调整去除 [n]
48 - # 更精确:从 ** 后到 ** 前
49 - sub(/.*\[\*\*/, "", line)
50 - sub(/\*\*\].*/, "", line)
51 - name = line
52 - } else {
53 - name = ""
54 - }
55 -
56 - # 重置 line 为原始
57 - line = $0
58 -
59 - # 提取官方 ID:去除 `
60 - if (match(line, /`([^`]+)`/)) {
61 - id_official = substr(line, RSTART + 1, RLENGTH - 2)
62 - } else {
63 - id_official = ""
64 - }
65 -
66 - # 提取其他 ID:第三列,通常 -
67 - sub(/.*\| [^|]* \| [^|]* \| /, "", line) # 临时去除到第三列后
68 - if (match(line, /^ ([^ |]+) /)) {
69 - id_other = substr(line, RSTART + 1, RLENGTH - 2)
70 - } else {
71 - id_other = "-"
72 - }
73 -
74 - # 提取描述:第五列(最后一列)
75 - if (match($0, /\| ([^|]+) \| ([^|]+) \| ([^|]+) \| (.*) \|$/)) {
76 - desc = substr($0, RSTART + RLENGTH - length($4) - 1) # 复杂,改用 split
77 - }
78 -
79 - # 更可靠方式:用 split 分隔 |
42 + BEGIN {
43 + print "名称 扩展 ID (官方) 扩展 ID() 描述"
44 + print "-----------------------------------------------------------------------------------------------"
45 + }
46 + /^\| \[\*\*[^\]]+\]\[\d+\] \| `/ {
47 + # 用 split 分隔 |
80 48 split($0, fields, "|")
81 - if (length(fields) >= 5) {
82 - name_field = fields[2]
83 - gsub(/^[ \t]+|[ \t]+$/, "", name_field)
84 - gsub(/\[\*\*[^*]+\*\*\]\[\d+\]/, "", name_field) # 去除链接部分,留空? 等下已提取name
85 - # 用之前提取的 name
86 49
87 - id_official_field = fields[3]
88 - gsub(/^[ \t]+|[ \t]+$/, "", id_official_field)
89 - gsub(/`/, "", id_official_field)
50 + # 名称(去除 Markdown 链接和粗体)
51 + name = fields[2]
52 + gsub(/^[ \t]+|[ \t]+$/, "", name)
53 + gsub(/\[\*\*[^\*]+\*\*\]\[\d+\]/, "", name)
54 + gsub(/^\*\*|\*\*$/, "", name) # 万一残留
90 55
91 - id_other_field = fields[4]
92 - gsub(/^[ \t]+|[ \t]+$/, "", id_other_field)
56 + # 官方 ID(去除 ` 和空格)
57 + id_official = fields[3]
58 + gsub(/^[ \t]+|[ \t]+$|`/, "", id_official)
93 59
94 - desc_field = fields[5]
95 - gsub(/^[ \t]+|[ \t]+$/, "", desc_field)
60 + # 其他 ID
61 + id_other = fields[4]
62 + gsub(/^[ \t]+|[ \t]+$/, "", id_other)
96 63
97 - printf "%s %s %s %s\n", name, id_official_field, id_other_field, desc_field
98 - }
64 + # 描述
65 + desc = fields[5]
66 + gsub(/^[ \t]+|[ \t]+$/, "", desc)
67 +
68 + # 格式化输出(固定宽度对齐)
69 + printf "%-30s %-35s %-10s %s\n", name, id_official, id_other, desc
99 70 }'
100 71 exit 0
101 72 fi