Skip to content

Commit c83fd0b

Browse files
Shell session: Commands prefixed with a path are now detected (#2686)
1 parent 88a17b4 commit c83fd0b

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

components/prism-shell-session.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,19 @@
1515

1616
Prism.languages['shell-session'] = {
1717
'command': {
18-
pattern: RegExp(/^(?:[^\s@:$#*!/\\]+@[^\s@:$#*!/\\]+(?::[^\0-\x1F$#*?"<>:;|]+)?)?[$#](?:[^\\\r\n'"<]|\\.|<<str>>)+/.source.replace(/<<str>>/g, function () { return strings; }), 'm'),
18+
pattern: RegExp(/^(?:[^\s@:$#*!/\\]+@[^\s@:$#*!/\\]+(?::[^\0-\x1F$#*?"<>:;|]+)?|[^\0-\x1F$#*?"<>:;|]+)?[$#](?:[^\\\r\n'"<]|\\.|<<str>>)+/.source.replace(/<<str>>/g, function () { return strings; }), 'm'),
1919
greedy: true,
2020
inside: {
2121
'info': {
2222
// foo@bar:~/files$ exit
2323
// foo@bar$ exit
24+
// ~/files$ exit
2425
pattern: /^[^#$]+/,
2526
alias: 'punctuation',
2627
inside: {
27-
'path': {
28-
pattern: /(:)[\s\S]+/,
29-
lookbehind: true
30-
},
31-
'user': /^[^:]+/,
32-
'punctuation': /:/
28+
'user': /^[^\s@:$#*!/\\]+@[^\s@:$#*!/\\]+/,
29+
'punctuation': /:/,
30+
'path': /[\s\S]+/
3331
}
3432
},
3533
'bash': {

components/prism-shell-session.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/home/user$ echo "Hello World"
2+
Hello World
3+
/home/user$ exit
4+
5+
----------------------------------------------------
6+
7+
[
8+
["command", [
9+
["info", [
10+
["path", "/home/user"]
11+
]],
12+
["shell-symbol", "$"],
13+
["bash", [
14+
["builtin", "echo"],
15+
["string", ["\"Hello World\""]]
16+
]]
17+
]],
18+
19+
["output", "Hello World\r\n"],
20+
["command", [
21+
["info", [
22+
["path", "/home/user"]
23+
]],
24+
["shell-symbol", "$"],
25+
["bash", [
26+
["builtin", "exit"]
27+
]]
28+
]]
29+
]

0 commit comments

Comments
 (0)