jetsung revised this gist 5 months ago. Go to revision
1 file changed, 21 insertions, 31 deletions
install
| @@ -38,50 +38,40 @@ fi | |||
| 38 | 38 | if $VERBOSE; then | |
| 39 | 39 | echo | |
| 40 | 40 | curl -s --fail "$URL_DESC" | awk ' | |
| 41 | - | BEGIN { | |
| 42 | - | in_table = 0 | |
| 43 | - | } | |
| 44 | - | # 跳过表头和分隔行 | |
| 45 | - | /^\|/ && !in_table { | |
| 46 | - | if ($0 ~ /\| 名称 \|/) { | |
| 47 | - | in_table = 1 | |
| 48 | - | next | |
| 49 | - | } | |
| 50 | - | if ($0 ~ /---/) { | |
| 51 | - | next | |
| 52 | - | } | |
| 53 | - | } | |
| 54 | - | # 处理表格数据行 | |
| 55 | - | in_table && /^\|/ && $0 ~ /\| \[.*\]/ { | |
| 56 | - | # 按 | 分割,字段从 1 开始,fields[0] 是空 | |
| 41 | + | # 只处理看起来像扩展数据行的行:以 | [ 开头,且包含反引号 ID | |
| 42 | + | /^\| \[/ && /\| `[^`]+` \|/ { | |
| 43 | + | # 按 | 分割 | |
| 57 | 44 | split($0, fields, "\\|") | |
| 58 | - | if (length(fields) < 5) next | |
| 45 | + | if (length(fields) < 6) next | |
| 59 | 46 | ||
| 60 | - | # 提取名称:fields[2],如 "[**Even Better TOML**][6]" | |
| 47 | + | # === 提取名称(fields[2])=== | |
| 61 | 48 | name_raw = fields[2] | |
| 62 | - | gsub(/^[ \t]+|[ \\t]+$/, "", name_raw) | |
| 49 | + | gsub(/^[ \t]+|[ \t]+$/, "", name_raw) | |
| 63 | 50 | # 提取 **...** 中的内容 | |
| 64 | 51 | if (match(name_raw, /\*\*([^*]+)\*\*/)) { | |
| 65 | 52 | name = substr(name_raw, RSTART + 2, RLENGTH - 4) | |
| 66 | 53 | } else { | |
| 67 | - | name = name_raw | |
| 54 | + | # 如果没有加粗,尝试提取 [text][ref] 中的 text | |
| 55 | + | if (match(name_raw, /^\[([^]]+)\]/)) { | |
| 56 | + | name = substr(name_raw, RSTART + 1, RLENGTH - 2) | |
| 57 | + | } else { | |
| 58 | + | name = name_ | |
| 59 | + | } | |
| 68 | 60 | } | |
| 69 | 61 | ||
| 70 | - | # 官方 ID:fields[3],如 "`tamasfe.even-better-toml`" | |
| 71 | - | id_official = fields[3] | |
| 72 | - | gsub(/^[ \t]+|[ \t]+$/, "", id_official) | |
| 73 | - | gsub(/`/, "", id_official) | |
| 62 | + | # === 提取扩展 ID(fields[3])=== | |
| 63 | + | id = fields[3] | |
| 64 | + | gsub(/^[ \t]+|[ \t]+$/, "", id) | |
| 65 | + | gsub(/`/g, "", id) | |
| 74 | 66 | ||
| 75 | - | # 其他 ID:fields[4],如 "-" | |
| 76 | - | id_other = fields[4] | |
| 77 | - | gsub(/^[ \t]+|[ \t]+$/, "", id_other) | |
| 78 | - | gsub(/`/, "", id_other) | |
| 79 | - | ||
| 80 | - | # 描述:fields[5] | |
| 67 | + | # === 提取描述(fields[5])=== | |
| 81 | 68 | desc = fields[5] | |
| 82 | 69 | gsub(/^[ \t]+|[ \t]+$/, "", desc) | |
| 83 | 70 | ||
| 84 | - | printf "名称: %s\n扩展ID: %s\n扩展ID: %s\n描述: %s\n\n", name, id_official, id_other, desc | |
| 71 | + | # 跳过空值 | |
| 72 | + | if (name == "" || id == "" || desc == "") next | |
| 73 | + | ||
| 74 | + | printf "名称: %s\n扩展ID: %s\n描述: %s\n\n", name, id, desc | |
| 85 | 75 | }' | |
| 86 | 76 | echo | |
| 87 | 77 | exit 0 | |
jetsung revised this gist 5 months ago. Go to revision
1 file changed, 6 insertions, 1 deletion
install
| @@ -72,11 +72,16 @@ if $VERBOSE; then | |||
| 72 | 72 | gsub(/^[ \t]+|[ \t]+$/, "", id_official) | |
| 73 | 73 | gsub(/`/, "", id_official) | |
| 74 | 74 | ||
| 75 | + | # 其他 ID:fields[4],如 "-" | |
| 76 | + | id_other = fields[4] | |
| 77 | + | gsub(/^[ \t]+|[ \t]+$/, "", id_other) | |
| 78 | + | gsub(/`/, "", id_other) | |
| 79 | + | ||
| 75 | 80 | # 描述:fields[5] | |
| 76 | 81 | desc = fields[5] | |
| 77 | 82 | gsub(/^[ \t]+|[ \t]+$/, "", desc) | |
| 78 | 83 | ||
| 79 | - | printf "名称: %s\n扩展ID: %s\n描述: %s\n\n", name, id_official, desc | |
| 84 | + | printf "名称: %s\n扩展ID: %s\n扩展ID: %s\n描述: %s\n\n", name, id_official, id_other, desc | |
| 80 | 85 | }' | |
| 81 | 86 | echo | |
| 82 | 87 | exit 0 | |
jetsung revised this gist 5 months ago. Go to revision
1 file changed, 38 insertions, 40 deletions
install
| @@ -38,47 +38,45 @@ fi | |||
| 38 | 38 | if $VERBOSE; then | |
| 39 | 39 | echo | |
| 40 | 40 | curl -s --fail "$URL_DESC" | awk ' | |
| 41 | - | BEGIN { | |
| 42 | - | in_table = 0 | |
| 43 | - | } | |
| 44 | - | # 跳过表头 | |
| 45 | - | /^\| 名称 \| 扩展 ID \| 链接 \| 描述 \|/ { | |
| 46 | - | in_table = 1 | |
| 47 | - | next | |
| 48 | - | } | |
| 49 | - | # 跳过分隔行(---) | |
| 50 | - | in_table && /^[|][-| ]+$/ { | |
| 51 | - | next | |
| 52 | - | } | |
| 53 | - | # 处理数据行 | |
| 54 | - | in_table && /^\|/ && NF >= 5 { | |
| 55 | - | split($0, fields, "\\|") | |
| 56 | - | if (length(fields) < 6) next | |
| 57 | - | ||
| 58 | - | # 提取名称(第二列) | |
| 59 | - | name_raw = fields[2] | |
| 60 | - | gsub(/^[ \t]+|[ \t]+$/, "", name_raw) | |
| 61 | - | if (match(name_raw, /\*\*([^*]+)\*\*/)) { | |
| 62 | - | name = substr(name_raw, RSTART + 2, RLENGTH - 4) | |
| 63 | - | } else { | |
| 64 | - | # 去除 [name][ref] 中的链接部分,保留文字 | |
| 65 | - | gsub(/\[([^]]+)\]\[[^]]+\]/, "\\1", name_raw) | |
| 66 | - | name = name_raw | |
| 41 | + | BEGIN { | |
| 42 | + | in_table = 0 | |
| 67 | 43 | } | |
| 68 | - | ||
| 69 | - | # 提取扩展 ID(第三列),去除反引号 | |
| 70 | - | id = fields[3] | |
| 71 | - | gsub(/^[ \t]+|[ \t]+$/, "", id) | |
| 72 | - | gsub(/`/g, "", id) | |
| 73 | - | ||
| 74 | - | # 提取描述(第五列) | |
| 75 | - | desc = fields[5] | |
| 76 | - | gsub(/^[ \t]+|[ \t]+$/, "", desc) | |
| 77 | - | ||
| 78 | - | # 跳过分隔符行或无效行 | |
| 79 | - | if (name == "" || id == "") next | |
| 80 | - | ||
| 81 | - | printf "名称: %s\n扩展ID: %s\n描述: %s\n\n", name, id, desc | |
| 44 | + | # 跳过表头和分隔行 | |
| 45 | + | /^\|/ && !in_table { | |
| 46 | + | if ($0 ~ /\| 名称 \|/) { | |
| 47 | + | in_table = 1 | |
| 48 | + | next | |
| 49 | + | } | |
| 50 | + | if ($0 ~ /---/) { | |
| 51 | + | next | |
| 52 | + | } | |
| 53 | + | } | |
| 54 | + | # 处理表格数据行 | |
| 55 | + | in_table && /^\|/ && $0 ~ /\| \[.*\]/ { | |
| 56 | + | # 按 | 分割,字段从 1 开始,fields[0] 是空 | |
| 57 | + | split($0, fields, "\\|") | |
| 58 | + | if (length(fields) < 5) next | |
| 59 | + | ||
| 60 | + | # 提取名称:fields[2],如 "[**Even Better TOML**][6]" | |
| 61 | + | name_raw = fields[2] | |
| 62 | + | gsub(/^[ \t]+|[ \\t]+$/, "", name_raw) | |
| 63 | + | # 提取 **...** 中的内容 | |
| 64 | + | if (match(name_raw, /\*\*([^*]+)\*\*/)) { | |
| 65 | + | name = substr(name_raw, RSTART + 2, RLENGTH - 4) | |
| 66 | + | } else { | |
| 67 | + | name = name_raw | |
| 68 | + | } | |
| 69 | + | ||
| 70 | + | # 官方 ID:fields[3],如 "`tamasfe.even-better-toml`" | |
| 71 | + | id_official = fields[3] | |
| 72 | + | gsub(/^[ \t]+|[ \t]+$/, "", id_official) | |
| 73 | + | gsub(/`/, "", id_official) | |
| 74 | + | ||
| 75 | + | # 描述:fields[5] | |
| 76 | + | desc = fields[5] | |
| 77 | + | gsub(/^[ \t]+|[ \t]+$/, "", desc) | |
| 78 | + | ||
| 79 | + | printf "名称: %s\n扩展ID: %s\n描述: %s\n\n", name, id_official, desc | |
| 82 | 80 | }' | |
| 83 | 81 | echo | |
| 84 | 82 | exit 0 | |
jetsung revised this gist 5 months ago. Go to revision
1 file changed, 69 insertions, 110 deletions
install
| @@ -1,20 +1,21 @@ | |||
| 1 | 1 | #!/usr/bin/env bash | |
| 2 | 2 | ||
| 3 | - | BASE_URL="https://gist.asfd.cn/jetsung/vscode/raw/HEAD/" | |
| 4 | - | DESC_FILE="README.md" | |
| 5 | - | IDE_CMD="code" | |
| 3 | + | BASE_URL="https://gist.asfd.cn/jetsung/vscode/raw/HEAD/ " | |
| 4 | + | LIST_FILE="index.txt" # 默认扩展 ID 列表文件 | |
| 5 | + | DESC_FILE="README.md" # 描述 Markdown 文件 | |
| 6 | + | IDE_CMD="code" # 默认 VSCode | |
| 6 | 7 | FORCE=false | |
| 7 | 8 | EXTRA="" | |
| 8 | - | VERBOSE=false | |
| 9 | + | VERBOSE=false # -v: 只显示详细扩展信息(纯文本单行格式),不安装 | |
| 9 | 10 | ||
| 10 | - | # 参数解析 | |
| 11 | + | # 参数解析函数 | |
| 11 | 12 | parameters() { | |
| 12 | 13 | while getopts "s:f e:n:v" opt; do | |
| 13 | 14 | case $opt in | |
| 14 | 15 | s) IDE_CMD="$OPTARG" ;; | |
| 15 | 16 | f) FORCE=true ;; | |
| 16 | 17 | e) EXTRA="$OPTARG" ;; | |
| 17 | - | n) DESC_FILE="$OPTARG" ;; # -n now sets the README/md file | |
| 18 | + | n) LIST_FILE="$OPTARG" ;; | |
| 18 | 19 | v) VERBOSE=true ;; | |
| 19 | 20 | \?) echo "无效参数: -$OPTARG" >&2; exit 1 ;; | |
| 20 | 21 | esac | |
| @@ -23,116 +24,74 @@ parameters() { | |||
| 23 | 24 | EXTRA="$EXTRA $@" | |
| 24 | 25 | } | |
| 25 | 26 | ||
| 26 | - | extract_extensions() { | |
| 27 | - | local content | |
| 28 | - | if [[ "$DESC_FILE" == http* ]]; then | |
| 29 | - | content=$(curl -s --fail "$DESC_FILE") | |
| 30 | - | elif [[ -f "$DESC_FILE" ]]; then | |
| 31 | - | content=$(cat "$DESC_FILE") | |
| 32 | - | else | |
| 33 | - | content=$(curl -s --fail "${BASE_URL}${DESC_FILE}") | |
| 34 | - | fi | |
| 35 | - | ||
| 36 | - | if [ $? -ne 0 ] || [ -z "$content" ]; then | |
| 37 | - | echo "错误:无法加载 README 文件($DESC_FILE)" >&2 | |
| 38 | - | exit 1 | |
| 39 | - | fi | |
| 27 | + | # 主函数 | |
| 28 | + | main() { | |
| 29 | + | parameters "$@" | |
| 40 | 30 | ||
| 41 | - | echo "$content" | awk ' | |
| 42 | - | BEGIN { | |
| 43 | - | in_table = 0 | |
| 44 | - | } | |
| 45 | - | # 检测表头行 | |
| 46 | - | /^\|/ && $0 ~ /\| 名称 \| 扩展 ID \|/ { | |
| 47 | - | in_table = 1 | |
| 48 | - | next | |
| 49 | - | } | |
| 50 | - | # 跳过分隔行(如 |:---|:---|...) | |
| 51 | - | in_table && /^\|[-:| ]+\|$/ { next } | |
| 52 | - | # 处理数据行 | |
| 53 | - | in_table && /^\|/ { | |
| 54 | - | gsub(/^\|/, "", $0) | |
| 55 | - | gsub(/\|$/, "", $0) | |
| 56 | - | n = split($0, fields, "\\|") | |
| 57 | - | if (n >= 4) { | |
| 58 | - | id = fields[2] | |
| 59 | - | gsub(/^[ \t]*`?/, "", id) | |
| 60 | - | gsub(/`?[ \t]*$/, "", id) | |
| 61 | - | if (id != "" && id != "-") { | |
| 62 | - | print id | |
| 63 | - | } | |
| 64 | - | } | |
| 65 | - | } | |
| 66 | - | # 遇到空行或非表格行,退出表格模式(可选增强) | |
| 67 | - | !/^\|/ && in_table { in_table = 0 } | |
| 68 | - | ' | |
| 69 | - | } | |
| 31 | + | # 处理 LIST_FILE | |
| 32 | + | if [[ "$LIST_FILE" != *.* ]]; then | |
| 33 | + | LIST_FILE="${LIST_FILE}.txt" | |
| 34 | + | fi | |
| 70 | 35 | ||
| 71 | - | show_verbose() { | |
| 72 | - | local content | |
| 73 | - | if [[ "$DESC_FILE" == http* ]]; then | |
| 74 | - | content=$(curl -s --fail "$DESC_FILE") | |
| 75 | - | elif [[ -f "$DESC_FILE" ]]; then | |
| 76 | - | content=$(cat "$DESC_FILE") | |
| 77 | - | else | |
| 78 | - | content=$(curl -s --fail "${BASE_URL}${DESC_FILE}") | |
| 79 | - | fi | |
| 36 | + | URL_DESC="${BASE_URL}${DESC_FILE}" | |
| 80 | 37 | ||
| 38 | + | if $VERBOSE; then | |
| 81 | 39 | echo | |
| 82 | - | echo "$content" | awk ' | |
| 83 | - | BEGIN { | |
| 84 | - | in_table = 0 | |
| 85 | - | } | |
| 86 | - | /^\|/ && $0 ~ /\| 名称 \| 扩展 ID \|/ { | |
| 87 | - | in_table = 1 | |
| 88 | - | next | |
| 89 | - | } | |
| 90 | - | in_table && /^\|[-:| ]+\|$/ { next } | |
| 91 | - | in_table && /^\|/ { | |
| 92 | - | gsub(/^\|/, "", $0) | |
| 93 | - | gsub(/\|$/, "", $0) | |
| 94 | - | n = split($0, fields, "\\|") | |
| 95 | - | if (n >= 5) { | |
| 96 | - | name_raw = fields[1] | |
| 97 | - | id = fields[2] | |
| 98 | - | desc = fields[4] | |
| 99 | - | ||
| 100 | - | # 提取 **...** 中的名称 | |
| 101 | - | if (match(name_raw, /\*\*([^*]+)\*\*/)) { | |
| 102 | - | name = substr(name_raw, RSTART+2, RLENGTH-4) | |
| 103 | - | } else { | |
| 104 | - | gsub(/[\[\]\*\`]/, "", name_raw) | |
| 105 | - | name = name_raw | |
| 106 | - | } | |
| 107 | - | ||
| 108 | - | gsub(/^[ \t]*`?/, "", id) | |
| 109 | - | gsub(/`?[ \t]*$/, "", id) | |
| 110 | - | gsub(/^[ \t]+|[ \t]+$/, "", desc) | |
| 111 | - | ||
| 112 | - | if (id != "" && id != "-") { | |
| 113 | - | printf "名称: %s\n扩展ID: %s\n描述: %s\n\n", name, id, desc | |
| 114 | - | } | |
| 115 | - | } | |
| 116 | - | } | |
| 117 | - | !/^\|/ && in_table { in_table = 0 } | |
| 118 | - | ' | |
| 119 | - | echo | |
| 40 | + | curl -s --fail "$URL_DESC" | awk ' | |
| 41 | + | BEGIN { | |
| 42 | + | in_table = 0 | |
| 43 | + | } | |
| 44 | + | # 跳过表头 | |
| 45 | + | /^\| 名称 \| 扩展 ID \| 链接 \| 描述 \|/ { | |
| 46 | + | in_table = 1 | |
| 47 | + | next | |
| 48 | + | } | |
| 49 | + | # 跳过分隔行(---) | |
| 50 | + | in_table && /^[|][-| ]+$/ { | |
| 51 | + | next | |
| 120 | 52 | } | |
| 53 | + | # 处理数据行 | |
| 54 | + | in_table && /^\|/ && NF >= 5 { | |
| 55 | + | split($0, fields, "\\|") | |
| 56 | + | if (length(fields) < 6) next | |
| 57 | + | ||
| 58 | + | # 提取名称(第二列) | |
| 59 | + | name_raw = fields[2] | |
| 60 | + | gsub(/^[ \t]+|[ \t]+$/, "", name_raw) | |
| 61 | + | if (match(name_raw, /\*\*([^*]+)\*\*/)) { | |
| 62 | + | name = substr(name_raw, RSTART + 2, RLENGTH - 4) | |
| 63 | + | } else { | |
| 64 | + | # 去除 [name][ref] 中的链接部分,保留文字 | |
| 65 | + | gsub(/\[([^]]+)\]\[[^]]+\]/, "\\1", name_raw) | |
| 66 | + | name = name_raw | |
| 67 | + | } | |
| 121 | 68 | ||
| 122 | - | # 主函数 | |
| 123 | - | main() { | |
| 124 | - | parameters "$@" | |
| 69 | + | # 提取扩展 ID(第三列),去除反引号 | |
| 70 | + | id = fields[3] | |
| 71 | + | gsub(/^[ \t]+|[ \t]+$/, "", id) | |
| 72 | + | gsub(/`/g, "", id) | |
| 125 | 73 | ||
| 126 | - | if $VERBOSE; then | |
| 127 | - | show_verbose | |
| 128 | - | exit 0 | |
| 129 | - | fi | |
| 74 | + | # 提取描述(第五列) | |
| 75 | + | desc = fields[5] | |
| 76 | + | gsub(/^[ \t]+|[ \t]+$/, "", desc) | |
| 130 | 77 | ||
| 131 | - | echo "正在从 $DESC_FILE 提取扩展列表..." | |
| 132 | - | EXTENSIONS=$(extract_extensions) | |
| 78 | + | # 跳过分隔符行或无效行 | |
| 79 | + | if (name == "" || id == "") next | |
| 80 | + | ||
| 81 | + | printf "名称: %s\n扩展ID: %s\n描述: %s\n\n", name, id, desc | |
| 82 | + | }' | |
| 83 | + | echo | |
| 84 | + | exit 0 | |
| 85 | + | fi | |
| 86 | + | ||
| 87 | + | # 非 -v 模式:正常下载 index.txt 并安装 | |
| 88 | + | URL_LIST="${BASE_URL}${LIST_FILE}" | |
| 89 | + | ||
| 90 | + | echo "从 $URL_LIST 下载扩展列表..." | |
| 91 | + | EXTENSIONS=$(curl -s --fail "$URL_LIST" | grep -v '^#' | grep -v '^$' | sed '/^$/d') | |
| 133 | 92 | ||
| 134 | 93 | if [ -z "$EXTENSIONS" ]; then | |
| 135 | - | echo "错误:未找到有效的扩展 ID 列表!" >&2 | |
| 94 | + | echo "错误: 未获取到扩展列表或文件为空!请检查文件名(当前: $LIST_FILE)。" >&2 | |
| 136 | 95 | exit 1 | |
| 137 | 96 | fi | |
| 138 | 97 | ||
| @@ -143,14 +102,14 @@ main() { | |||
| 143 | 102 | ||
| 144 | 103 | echo "开始为 $IDE_CMD 安装扩展(命令: $BASE_CMD ... $EXTRA)" | |
| 145 | 104 | echo "扩展列表:" | |
| 146 | - | echo "$EXTENSIONS" | |
| 105 | + | echo "$EXTENSIONS" | tr ' ' '\n' | |
| 147 | 106 | echo "-----------------" | |
| 148 | 107 | ||
| 149 | - | while IFS= read -r ext; do | |
| 108 | + | echo "$EXTENSIONS" | tr ' ' '\n' | while read -r ext; do | |
| 150 | 109 | [ -z "$ext" ] && continue | |
| 151 | 110 | echo "安装: $ext" | |
| 152 | - | $BASE_CMD "$ext" $EXTRA || echo "警告: 安装 $ext 失败(可能已安装或 ID 无效)" | |
| 153 | - | done <<< "$EXTENSIONS" | |
| 111 | + | $BASE_CMD "$ext" $EXTRA || echo "警告: 安装 $ext 失败(可能已安装或 ID 不兼容)" | |
| 112 | + | done | |
| 154 | 113 | ||
| 155 | 114 | echo "-----------------" | |
| 156 | 115 | echo "所有扩展安装完成!请重启 IDE 以生效。" | |
jetsung revised this gist 5 months ago. Go to revision
1 file changed, 15 insertions, 13 deletions
install
| @@ -23,7 +23,6 @@ parameters() { | |||
| 23 | 23 | EXTRA="$EXTRA $@" | |
| 24 | 24 | } | |
| 25 | 25 | ||
| 26 | - | # 从 README.md 提取扩展 ID 列表(仅官方扩展 ID) | |
| 27 | 26 | extract_extensions() { | |
| 28 | 27 | local content | |
| 29 | 28 | if [[ "$DESC_FILE" == http* ]]; then | |
| @@ -43,17 +42,20 @@ extract_extensions() { | |||
| 43 | 42 | BEGIN { | |
| 44 | 43 | in_table = 0 | |
| 45 | 44 | } | |
| 46 | - | /^\|/ && /名称.*扩展 ID/ { | |
| 45 | + | # 检测表头行 | |
| 46 | + | /^\|/ && $0 ~ /\| 名称 \| 扩展 ID \|/ { | |
| 47 | 47 | in_table = 1 | |
| 48 | 48 | next | |
| 49 | 49 | } | |
| 50 | - | in_table && /^\|[-| ]+$/ { next } # 跳过分隔行 | |
| 50 | + | # 跳过分隔行(如 |:---|:---|...) | |
| 51 | + | in_table && /^\|[-:| ]+\|$/ { next } | |
| 52 | + | # 处理数据行 | |
| 51 | 53 | in_table && /^\|/ { | |
| 52 | 54 | gsub(/^\|/, "", $0) | |
| 53 | 55 | gsub(/\|$/, "", $0) | |
| 54 | - | split($0, fields, " \\| ") | |
| 55 | - | if (length(fields) >= 3) { | |
| 56 | - | id = fields[2] # "扩展 ID" 是第二列(fields[1] 是名称) | |
| 56 | + | n = split($0, fields, "\\|") | |
| 57 | + | if (n >= 4) { | |
| 58 | + | id = fields[2] | |
| 57 | 59 | gsub(/^[ \t]*`?/, "", id) | |
| 58 | 60 | gsub(/`?[ \t]*$/, "", id) | |
| 59 | 61 | if (id != "" && id != "-") { | |
| @@ -61,11 +63,11 @@ extract_extensions() { | |||
| 61 | 63 | } | |
| 62 | 64 | } | |
| 63 | 65 | } | |
| 64 | - | /^$/ { in_table = 0 } # 表格结束 | |
| 66 | + | # 遇到空行或非表格行,退出表格模式(可选增强) | |
| 67 | + | !/^\|/ && in_table { in_table = 0 } | |
| 65 | 68 | ' | |
| 66 | 69 | } | |
| 67 | 70 | ||
| 68 | - | # 显示详细信息(-v 模式) | |
| 69 | 71 | show_verbose() { | |
| 70 | 72 | local content | |
| 71 | 73 | if [[ "$DESC_FILE" == http* ]]; then | |
| @@ -81,16 +83,16 @@ show_verbose() { | |||
| 81 | 83 | BEGIN { | |
| 82 | 84 | in_table = 0 | |
| 83 | 85 | } | |
| 84 | - | /^\|/ && /名称.*扩展 ID/ { | |
| 86 | + | /^\|/ && $0 ~ /\| 名称 \| 扩展 ID \|/ { | |
| 85 | 87 | in_table = 1 | |
| 86 | 88 | next | |
| 87 | 89 | } | |
| 88 | - | in_table && /^\|[-| ]+$/ { next } | |
| 90 | + | in_table && /^\|[-:| ]+\|$/ { next } | |
| 89 | 91 | in_table && /^\|/ { | |
| 90 | 92 | gsub(/^\|/, "", $0) | |
| 91 | 93 | gsub(/\|$/, "", $0) | |
| 92 | - | split($0, fields, " \\| ") | |
| 93 | - | if (length(fields) >= 4) { | |
| 94 | + | n = split($0, fields, "\\|") | |
| 95 | + | if (n >= 5) { | |
| 94 | 96 | name_raw = fields[1] | |
| 95 | 97 | id = fields[2] | |
| 96 | 98 | desc = fields[4] | |
| @@ -112,7 +114,7 @@ show_verbose() { | |||
| 112 | 114 | } | |
| 113 | 115 | } | |
| 114 | 116 | } | |
| 115 | - | /^$/ { in_table = 0 } | |
| 117 | + | !/^\|/ && in_table { in_table = 0 } | |
| 116 | 118 | ' | |
| 117 | 119 | echo | |
| 118 | 120 | } | |
jetsung revised this gist 5 months ago. Go to revision
1 file changed, 103 insertions, 67 deletions
install
| @@ -1,21 +1,20 @@ | |||
| 1 | 1 | #!/usr/bin/env bash | |
| 2 | 2 | ||
| 3 | 3 | BASE_URL="https://gist.asfd.cn/jetsung/vscode/raw/HEAD/" | |
| 4 | - | LIST_FILE="index.txt" # 默认扩展 ID 列表文件 | |
| 5 | - | DESC_FILE="README.md" # 描述 Markdown 文件 | |
| 6 | - | IDE_CMD="code" # 默认 VSCode | |
| 4 | + | DESC_FILE="README.md" | |
| 5 | + | IDE_CMD="code" | |
| 7 | 6 | FORCE=false | |
| 8 | 7 | EXTRA="" | |
| 9 | - | VERBOSE=false # -v: 只显示详细扩展信息(纯文本单行格式),不安装 | |
| 8 | + | VERBOSE=false | |
| 10 | 9 | ||
| 11 | - | # 参数解析函数 | |
| 10 | + | # 参数解析 | |
| 12 | 11 | parameters() { | |
| 13 | 12 | while getopts "s:f e:n:v" opt; do | |
| 14 | 13 | case $opt in | |
| 15 | 14 | s) IDE_CMD="$OPTARG" ;; | |
| 16 | 15 | f) FORCE=true ;; | |
| 17 | 16 | e) EXTRA="$OPTARG" ;; | |
| 18 | - | n) LIST_FILE="$OPTARG" ;; | |
| 17 | + | n) DESC_FILE="$OPTARG" ;; # -n now sets the README/md file | |
| 19 | 18 | v) VERBOSE=true ;; | |
| 20 | 19 | \?) echo "无效参数: -$OPTARG" >&2; exit 1 ;; | |
| 21 | 20 | esac | |
| @@ -24,77 +23,114 @@ parameters() { | |||
| 24 | 23 | EXTRA="$EXTRA $@" | |
| 25 | 24 | } | |
| 26 | 25 | ||
| 27 | - | # 主函数 | |
| 28 | - | main() { | |
| 29 | - | parameters "$@" | |
| 30 | - | ||
| 31 | - | # 处理 LIST_FILE | |
| 32 | - | if [[ "$LIST_FILE" != *.* ]]; then | |
| 33 | - | LIST_FILE="${LIST_FILE}.txt" | |
| 34 | - | fi | |
| 26 | + | # 从 README.md 提取扩展 ID 列表(仅官方扩展 ID) | |
| 27 | + | extract_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 | |
| 35 | 36 | ||
| 36 | - | URL_DESC="${BASE_URL}${DESC_FILE}" | |
| 37 | + | if [ $? -ne 0 ] || [ -z "$content" ]; then | |
| 38 | + | echo "错误:无法加载 README 文件($DESC_FILE)" >&2 | |
| 39 | + | exit 1 | |
| 40 | + | fi | |
| 37 | 41 | ||
| 38 | - | if $VERBOSE; then | |
| 39 | - | echo | |
| 40 | - | curl -s --fail "$URL_DESC" | awk ' | |
| 42 | + | echo "$content" | awk ' | |
| 41 | 43 | BEGIN { | |
| 42 | 44 | in_table = 0 | |
| 43 | 45 | } | |
| 44 | - | # 跳过表头和分隔行 | |
| 45 | - | /^\|/ && !in_table { | |
| 46 | - | if ($0 ~ /\| 名称 \|/) { | |
| 47 | - | in_table = 1 | |
| 48 | - | next | |
| 49 | - | } | |
| 50 | - | if ($0 ~ /---/) { | |
| 51 | - | next | |
| 52 | - | } | |
| 46 | + | /^\|/ && /名称.*扩展 ID/ { | |
| 47 | + | in_table = 1 | |
| 48 | + | next | |
| 53 | 49 | } | |
| 54 | - | # 处理表格数据行 | |
| 55 | - | in_table && /^\|/ && $0 ~ /\| \[.*\]/ { | |
| 56 | - | # 按 | 分割,字段从 1 开始,fields[0] 是空 | |
| 57 | - | split($0, fields, "\\|") | |
| 58 | - | if (length(fields) < 5) next | |
| 59 | - | ||
| 60 | - | # 提取名称:fields[2],如 "[**Even Better TOML**][6]" | |
| 61 | - | name_raw = fields[2] | |
| 62 | - | gsub(/^[ \t]+|[ \\t]+$/, "", name_raw) | |
| 63 | - | # 提取 **...** 中的内容 | |
| 64 | - | if (match(name_raw, /\*\*([^*]+)\*\*/)) { | |
| 65 | - | name = substr(name_raw, RSTART + 2, RLENGTH - 4) | |
| 66 | - | } else { | |
| 67 | - | name = name_raw | |
| 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 | + | } | |
| 68 | 62 | } | |
| 63 | + | } | |
| 64 | + | /^$/ { in_table = 0 } # 表格结束 | |
| 65 | + | ' | |
| 66 | + | } | |
| 69 | 67 | ||
| 70 | - | # 官方 ID:fields[3],如 "`tamasfe.even-better-toml`" | |
| 71 | - | id_official = fields[3] | |
| 72 | - | gsub(/^[ \t]+|[ \t]+$/, "", id_official) | |
| 73 | - | gsub(/`/, "", id_official) | |
| 74 | - | ||
| 75 | - | # 其他 ID:fields[4],如 "-" | |
| 76 | - | id_other = fields[4] | |
| 77 | - | gsub(/^[ \t]+|[ \t]+$/, "", id_other) | |
| 78 | - | gsub(/`/, "", id_other) | |
| 79 | - | ||
| 80 | - | # 描述:fields[5] | |
| 81 | - | desc = fields[5] | |
| 82 | - | gsub(/^[ \t]+|[ \t]+$/, "", desc) | |
| 68 | + | # 显示详细信息(-v 模式) | |
| 69 | + | show_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 | |
| 83 | 78 | ||
| 84 | - | printf "名称: %s\n扩展ID: %s\n扩展ID: %s\n描述: %s\n\n", name, id_official, id_other, desc | |
| 85 | - | }' | |
| 86 | 79 | echo | |
| 87 | - | exit 0 | |
| 88 | - | fi | |
| 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 | + | } | |
| 89 | 119 | ||
| 90 | - | # 非 -v 模式:正常下载 index.txt 并安装 | |
| 91 | - | URL_LIST="${BASE_URL}${LIST_FILE}" | |
| 120 | + | # 主函数 | |
| 121 | + | main() { | |
| 122 | + | parameters "$@" | |
| 92 | 123 | ||
| 93 | - | echo "从 $URL_LIST 下载扩展列表..." | |
| 94 | - | EXTENSIONS=$(curl -s --fail "$URL_LIST" | grep -v '^#' | grep -v '^$' | sed '/^$/d') | |
| 124 | + | if $VERBOSE; then | |
| 125 | + | show_verbose | |
| 126 | + | exit 0 | |
| 127 | + | fi | |
| 128 | + | ||
| 129 | + | echo "正在从 $DESC_FILE 提取扩展列表..." | |
| 130 | + | EXTENSIONS=$(extract_extensions) | |
| 95 | 131 | ||
| 96 | 132 | if [ -z "$EXTENSIONS" ]; then | |
| 97 | - | echo "错误: 未获取到扩展列表或文件为空!请检查文件名(当前: $LIST_FILE)。" >&2 | |
| 133 | + | echo "错误:未找到有效的扩展 ID 列表!" >&2 | |
| 98 | 134 | exit 1 | |
| 99 | 135 | fi | |
| 100 | 136 | ||
| @@ -105,14 +141,14 @@ fi | |||
| 105 | 141 | ||
| 106 | 142 | echo "开始为 $IDE_CMD 安装扩展(命令: $BASE_CMD ... $EXTRA)" | |
| 107 | 143 | echo "扩展列表:" | |
| 108 | - | echo "$EXTENSIONS" | tr ' ' '\n' | |
| 144 | + | echo "$EXTENSIONS" | |
| 109 | 145 | echo "-----------------" | |
| 110 | 146 | ||
| 111 | - | echo "$EXTENSIONS" | tr ' ' '\n' | while read -r ext; do | |
| 147 | + | while IFS= read -r ext; do | |
| 112 | 148 | [ -z "$ext" ] && continue | |
| 113 | 149 | echo "安装: $ext" | |
| 114 | - | $BASE_CMD "$ext" $EXTRA || echo "警告: 安装 $ext 失败(可能已安装或 ID 不兼容)" | |
| 115 | - | done | |
| 150 | + | $BASE_CMD "$ext" $EXTRA || echo "警告: 安装 $ext 失败(可能已安装或 ID 无效)" | |
| 151 | + | done <<< "$EXTENSIONS" | |
| 116 | 152 | ||
| 117 | 153 | echo "-----------------" | |
| 118 | 154 | echo "所有扩展安装完成!请重启 IDE 以生效。" | |
jetsung revised this gist 5 months ago. Go to revision
1 file changed, 12 insertions, 4 deletions
README.md
| @@ -1,15 +1,23 @@ | |||
| 1 | 1 | # VS Code 扩展推荐 | |
| 2 | 2 | ||
| 3 | 3 | ## 扩展列表 | |
| 4 | - | | 名称 | 扩展 ID (官方) | 扩展 ID() | 描述 | | |
| 4 | + | | 名称 | 扩展 ID | 链接 | 描述 | | |
| 5 | 5 | |:---|:---|:---|:---| | |
| 6 | - | | [**Even Better TOML**][6] | `tamasfe.even-better-toml` | - | 功能齐全的 TOML 支持 | | |
| 7 | - | | [**Choose a License**][7] | `ultram4rine.vscode-choosealicense` | - | 为你的项目选择一个许可证 | | |
| 8 | - | | [**gitignore**][8] | `codezombiech.gitignore` | - | 从 https://github.com/github/gitignore 仓库拉取 .gitignore 模板。支持.gitignore 文件的语言。 | | |
| 6 | + | | [**Even Better TOML**][6] | `tamasfe.even-better-toml` | [VSCode][6-1] - [OpenVSX][6-2] | 功能齐全的 TOML 支持 | | |
| 7 | + | | [**Choose a License**][7] | `ultram4rine.vscode-choosealicense` | [VSCode][7-1] - [OpenVSX][7-2] | 为你的项目选择一个许可证 | | |
| 8 | + | | [**gitignore**][8] | `codezombiech.gitignore` | [VSCode][8-1] - [OpenVSX][8-2] | 从 https://github.com/github/gitignore 仓库拉取 .gitignore 模板。支持.gitignore 文件的语言。 | | |
| 9 | 9 | ||
| 10 | 10 | [6]:https://github.com/tamasfe/taplo | |
| 11 | + | [6-1]:https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml | |
| 12 | + | [6-2]:https://open-vsx.org/extension/tamasfe/even-better-toml | |
| 13 | + | ||
| 11 | 14 | [7]:https://github.com/ultram4rine/vscode-choosealicense | |
| 15 | + | [7-1]:https://marketplace.visualstudio.com/items?itemName=ultram4rine.vscode-choosealicense | |
| 16 | + | [7-2]:https://open-vsx.org/extension/ultram4rine/vscode-choosealicense | |
| 17 | + | ||
| 12 | 18 | [8]:https://github.com/CodeZombieCH/vscode-gitignore | |
| 19 | + | [8-1]:https://marketplace.visualstudio.com/items?itemName=codezombiech.gitignore | |
| 20 | + | [8-2]:https://open-vsx.org/extension/codezombiech/gitignore | |
| 13 | 21 | ||
| 14 | 22 | - **微软官方:** https://marketplace.visualstudio.com/ | |
| 15 | 23 | - **Open VSX:** https://open-vsx.org/ | |
jetsung revised this gist 5 months ago. Go to revision
1 file changed, 2 insertions, 1 deletion
install
| @@ -70,11 +70,12 @@ if $VERBOSE; then | |||
| 70 | 70 | # 官方 ID:fields[3],如 "`tamasfe.even-better-toml`" | |
| 71 | 71 | id_official = fields[3] | |
| 72 | 72 | gsub(/^[ \t]+|[ \t]+$/, "", id_official) | |
| 73 | - | gsub(/`/g, "", id_official) | |
| 73 | + | gsub(/`/, "", id_official) | |
| 74 | 74 | ||
| 75 | 75 | # 其他 ID:fields[4],如 "-" | |
| 76 | 76 | id_other = fields[4] | |
| 77 | 77 | gsub(/^[ \t]+|[ \t]+$/, "", id_other) | |
| 78 | + | gsub(/`/, "", id_other) | |
| 78 | 79 | ||
| 79 | 80 | # 描述:fields[5] | |
| 80 | 81 | desc = fields[5] | |
jetsung revised this gist 5 months ago. Go to revision
1 file changed, 53 insertions, 69 deletions
install
| @@ -29,78 +29,62 @@ main() { | |||
| 29 | 29 | parameters "$@" | |
| 30 | 30 | ||
| 31 | 31 | # 处理 LIST_FILE | |
| 32 | - | if [[ "$LIST_FILE" != "*.*" ]] && [[ "$LIST_FILE" != *.* ]]; then | |
| 33 | - | LIST_FILE="${LIST_FILE}.txt" | |
| 34 | - | fi | |
| 32 | + | if [[ "$LIST_FILE" != *.* ]]; then | |
| 33 | + | LIST_FILE="${LIST_FILE}.txt" | |
| 34 | + | fi | |
| 35 | 35 | ||
| 36 | 36 | URL_DESC="${BASE_URL}${DESC_FILE}" | |
| 37 | 37 | ||
| 38 | - | if $VERBOSE; then | |
| 39 | - | echo | |
| 40 | - | # -v 模式:下载 README.md,先提取表格数据行(跳过标题和分隔行),然后逐行处理输出纯文本格式 | |
| 41 | - | curl -s --fail "$URL_DESC" | awk ' | |
| 42 | - | # 只处理数据行:以 "| [**" 开头(名称带链接) | |
| 43 | - | /^\| \[\*\*/ { | |
| 44 | - | line = $0 | |
| 45 | - | ||
| 46 | - | # 提取名称:去除 [**name**][n] | |
| 47 | - | if (match(line, /\[\*\*([^*]+)\*\*\]\[\d+\]/)) { | |
| 48 | - | name = substr(line, RSTART + 3, RLENGTH - 7 - length(match(line, /\[\d+\]/))) # 调整去除 [n] | |
| 49 | - | # 更精确:从 ** 后到 ** 前 | |
| 50 | - | sub(/.*\[\*\*/, "", line) | |
| 51 | - | sub(/\*\*\].*/, "", line) | |
| 52 | - | name = line | |
| 53 | - | } else { | |
| 54 | - | name = "" | |
| 55 | - | } | |
| 56 | - | echo $name | |
| 57 | - | ||
| 58 | - | # 重置 line 为原始 | |
| 59 | - | line = $0 | |
| 60 | - | ||
| 61 | - | # 提取官方 ID:去除 ` | |
| 62 | - | if (match(line, /`([^`]+)`/)) { | |
| 63 | - | id_official = substr(line, RSTART + 1, RLENGTH - 2) | |
| 64 | - | } else { | |
| 65 | - | id_official = "" | |
| 66 | - | } | |
| 67 | - | ||
| 68 | - | # 提取其他 ID:第三列,通常 - | |
| 69 | - | sub(/.*\| [^|]* \| [^|]* \| /, "", line) # 临时去除到第三列后 | |
| 70 | - | if (match(line, /^ ([^ |]+) /)) { | |
| 71 | - | id_other = substr(line, RSTART + 1, RLENGTH - 2) | |
| 72 | - | } else { | |
| 73 | - | id_other = "-" | |
| 74 | - | } | |
| 75 | - | ||
| 76 | - | # 提取描述:第五列(最后一列) | |
| 77 | - | if (match($0, /\| ([^|]+) \| ([^|]+) \| ([^|]+) \| (.*) \|$/)) { | |
| 78 | - | desc = substr($0, RSTART + RLENGTH - length($4) - 1) # 复杂,改用 split | |
| 79 | - | } | |
| 80 | - | ||
| 81 | - | # 更可靠方式:用 split 分隔 | | |
| 82 | - | split($0, fields, "|") | |
| 83 | - | if (length(fields) >= 5) { | |
| 84 | - | name_field = fields[2] | |
| 85 | - | gsub(/^[ \t]+|[ \t]+$/, "", name_field) | |
| 86 | - | # 用之前提取的 name | |
| 87 | - | ||
| 88 | - | id_official_field = fields[3] | |
| 89 | - | gsub(/^[ \t]+|[ \t]+$/, "", id_official_field) | |
| 90 | - | gsub(/`/, "", id_official_field) | |
| 91 | - | ||
| 92 | - | id_other_field = fields[4] | |
| 93 | - | gsub(/^[ \t]+|[ \t]+$/, "", id_other_field) | |
| 94 | - | ||
| 95 | - | desc_field = fields[5] | |
| 96 | - | gsub(/^[ \t]+|[ \t]+$/, "", desc_field) | |
| 97 | - | ||
| 98 | - | printf "名称: %s \n扩展ID: %s \n扩展ID: %s \n描述: %s\n\n", name, id_official_field, id_other_field, desc_field | |
| 99 | - | } | |
| 100 | - | }' | |
| 101 | - | echo | |
| 102 | - | exit 0 | |
| 103 | - | fi | |
| 38 | + | if $VERBOSE; then | |
| 39 | + | echo | |
| 40 | + | curl -s --fail "$URL_DESC" | awk ' | |
| 41 | + | BEGIN { | |
| 42 | + | in_table = 0 | |
| 43 | + | } | |
| 44 | + | # 跳过表头和分隔行 | |
| 45 | + | /^\|/ && !in_table { | |
| 46 | + | if ($0 ~ /\| 名称 \|/) { | |
| 47 | + | in_table = 1 | |
| 48 | + | next | |
| 49 | + | } | |
| 50 | + | if ($0 ~ /---/) { | |
| 51 | + | next | |
| 52 | + | } | |
| 53 | + | } | |
| 54 | + | # 处理表格数据行 | |
| 55 | + | in_table && /^\|/ && $0 ~ /\| \[.*\]/ { | |
| 56 | + | # 按 | 分割,字段从 1 开始,fields[0] 是空 | |
| 57 | + | split($0, fields, "\\|") | |
| 58 | + | if (length(fields) < 5) next | |
| 59 | + | ||
| 60 | + | # 提取名称:fields[2],如 "[**Even Better TOML**][6]" | |
| 61 | + | name_raw = fields[2] | |
| 62 | + | gsub(/^[ \t]+|[ \\t]+$/, "", name_raw) | |
| 63 | + | # 提取 **...** 中的内容 | |
| 64 | + | if (match(name_raw, /\*\*([^*]+)\*\*/)) { | |
| 65 | + | name = substr(name_raw, RSTART + 2, RLENGTH - 4) | |
| 66 | + | } else { | |
| 67 | + | name = name_raw | |
| 68 | + | } | |
| 69 | + | ||
| 70 | + | # 官方 ID:fields[3],如 "`tamasfe.even-better-toml`" | |
| 71 | + | id_official = fields[3] | |
| 72 | + | gsub(/^[ \t]+|[ \t]+$/, "", id_official) | |
| 73 | + | gsub(/`/g, "", id_official) | |
| 74 | + | ||
| 75 | + | # 其他 ID:fields[4],如 "-" | |
| 76 | + | id_other = fields[4] | |
| 77 | + | gsub(/^[ \t]+|[ \t]+$/, "", id_other) | |
| 78 | + | ||
| 79 | + | # 描述:fields[5] | |
| 80 | + | desc = fields[5] | |
| 81 | + | gsub(/^[ \t]+|[ \t]+$/, "", desc) | |
| 82 | + | ||
| 83 | + | printf "名称: %s\n扩展ID: %s\n扩展ID: %s\n描述: %s\n\n", name, id_official, id_other, desc | |
| 84 | + | }' | |
| 85 | + | echo | |
| 86 | + | exit 0 | |
| 87 | + | fi | |
| 104 | 88 | ||
| 105 | 89 | # 非 -v 模式:正常下载 index.txt 并安装 | |
| 106 | 90 | URL_LIST="${BASE_URL}${LIST_FILE}" | |
jetsung revised this gist 5 months ago. Go to revision
No changes