Skip to content

Commit d2187e6

Browse files
authored
[209_7] 补充bash代码的语法高亮支持 (#2651)
1 parent 9b15696 commit d2187e6

File tree

4 files changed

+83
-9
lines changed

4 files changed

+83
-9
lines changed

TeXmacs/plugins/bash/progs/code/bash-lang.scm

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@
4949
"history" "fc"
5050
"compgen" "complete"
5151
"times"
52-
"git" "ssh" "scp" "rsync" ;;常用外部命令
52+
)
53+
(external_command
54+
"ssh" "scp" "rsync" ;; 常用外部命令
5355
"curl" "wget"
5456
"xmake" "cmake" "make" "ninja"
5557
"gcc" "g++" "clang" "clang++"
@@ -59,9 +61,34 @@
5961
"tar" "zip" "unzip"
6062
"grep" "sed" "awk"
6163
"jq"
62-
"vim" "nvim"
63-
"sudo")
64-
64+
"sudo"
65+
"claude" "ll" "gh" "code" "gco"
66+
;; Git / GitHub
67+
"git" "gh"
68+
"gco" "gcb" "gcm" "gca" "gcp" "gst" "gpl" "gps"
69+
;; Editor / AI
70+
"code" "code-insiders" "vim" "nvim"
71+
"claude" "cursor" "zed"
72+
;; Common shell aliases
73+
"ll" "la" "l"
74+
;; GNU coreutils
75+
"arch" "basename" "b2sum" "base32" "base64" "basenc"
76+
"cat" "chcon" "chgrp" "chmod" "chown" "chroot"
77+
"cksum" "comm" "cp" "csplit" "cut" "date" "dd"
78+
"df" "dir" "dircolors" "dirname" "du"
79+
"env" "expand" "expr" "factor" "false" "fmt" "fold"
80+
"groups" "head" "hostid" "id" "install"
81+
"join" "link" "ln" "logname" "ls" "md5sum"
82+
"mkdir" "mkfifo" "mknod" "mktemp" "mv"
83+
"nice" "nl" "nohup" "nproc" "numfmt" "od"
84+
"paste" "pathchk" "pinky" "pr" "printenv" "ptx"
85+
"readlink" "realpath" "rm" "rmdir" "runcon"
86+
"seq" "sha1sum" "sha224sum" "sha256sum" "sha384sum" "sha512sum"
87+
"shred" "shuf" "sleep" "sort" "split" "stat"
88+
"stdbuf" "stty" "sum" "sync" "tac" "tail"
89+
"tee" "timeout" "touch" "tr" "true" "truncate"
90+
"tsort" "tty" "uname" "unexpand" "uniq" "unlink"
91+
"uptime" "users" "vdir" "wc" "who" "whoami" "yes")
6592
;; 关键字
6693
(keyword
6794
"if" "then" "elif" "else" "fi"
@@ -154,6 +181,7 @@
154181
("syntax:bash:constant_string" "dark grey" notify-bash-syntax)
155182
("syntax:bash:constant_char" "#333333" notify-bash-syntax)
156183
("syntax:bash:declare_function" "#0000c0" notify-bash-syntax)
184+
("syntax:bash:external_command" "#0000c0" notify-bash-syntax)
157185
("syntax:bash:declare_type" "#0000c0" notify-bash-syntax)
158186
("syntax:bash:operator" "#8b008b" notify-bash-syntax)
159187
("syntax:bash:operator_openclose" "#B02020" notify-bash-syntax)

TeXmacs/tests/tmu/209_7.tmu

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@
316316

317317
\;
318318

319-
# 常见 VCS / build / language commands
319+
# VCS / build / language commands
320320

321321
git status
322322

@@ -350,7 +350,7 @@
350350

351351
\;
352352

353-
# 网络 / 远程
353+
# net
354354

355355
ssh user@example.com true
356356

@@ -360,20 +360,52 @@
360360

361361
\;
362362

363-
# 容器 / 工具
363+
# docker
364364

365365
docker ps
366366

367367
docker run --rm alpine echo hello
368368

369369
\;
370370

371-
# 文本处理
371+
# text
372372

373373
grep -E "error\|warn" "$LOG" \| awk '{print NR ":" $0}' \| sed 's/^/LOG: /'
374374

375375
\;
376376

377+
# ---------- team tools / aliases highlight test ----------
378+
379+
\;
380+
381+
# shell aliases
382+
383+
ll
384+
385+
la
386+
387+
l
388+
389+
\;
390+
391+
# git / github aliases
392+
393+
git status
394+
395+
gh repo view
396+
397+
gco main
398+
399+
\;
400+
401+
# editor / ai tools
402+
403+
code .
404+
405+
claude help
406+
407+
\;
408+
377409
# ---------- final ----------
378410

379411
log INFO "DONE"

devel/209_7.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,18 @@
1313
- 高亮功能:TeXmacs/plugins/bash/progs/code/bash-lang.scm
1414
- 文档:TeXmacs/plugins/bash/doc/bash.en.tmu
1515

16-
## 2025/01/16
16+
17+
18+
## 2025/01/22
19+
### What
20+
补充了bash-lang.scm中语法高亮的定义,增加了
21+
- **外部命令高亮(external_command)**
22+
- GNU coreutils
23+
- 常用开发工具,如 `git``gh``code``claude`
24+
- 常用 alias(如 `ll``gco`
25+
26+
27+
## 2025/01/20
1728
### What
1829
为Mogan STEM添加Bash代码的语法高亮支持,包括语言定义文件和样式包。
1930

src/System/Language/language.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ initialize_color_encodings () {
244244
language_rep::color_encoding ("declare_type") = 33;
245245
language_rep::color_encoding ("declare_category") = 34;
246246
language_rep::color_encoding ("declare_module") = 35;
247+
language_rep::color_encoding ("external_command") = 36;
247248
language_rep::color_encoding ("operator") = 40;
248249
language_rep::color_encoding ("operator_openclose") = 41;
249250
language_rep::color_encoding ("operator_field") = 42;
@@ -297,6 +298,8 @@ initialize_color_decodings (string lan_name) {
297298
lan->color_decoding (34)=
298299
get_preference (pfx * "declare_category", "#d030d0");
299300
lan->color_decoding (35)= get_preference (pfx * "declare_module", "#0000c0");
301+
lan->color_decoding (36)=
302+
get_preference (pfx * "external_command", "#0000c0");
300303
lan->color_decoding (40)= get_preference (pfx * "operator", "#8b008b");
301304
lan->color_decoding (41)=
302305
get_preference (pfx * "operator_openclose", "#B02020");

0 commit comments

Comments
 (0)