Skip to content

Commit 8774e57

Browse files
authored
feat: add shellsession grammar (#483)
* feat: add shellsession grammar * feat: add sample
1 parent 3c41852 commit 8774e57

File tree

5 files changed

+61
-5
lines changed

5 files changed

+61
-5
lines changed

docs/languages.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ export type Lang =
185185
| 'scheme'
186186
| 'scss'
187187
| 'shaderlab' | 'shader'
188-
| 'shellscript' | 'bash' | 'console' | 'sh' | 'shell' | 'zsh'
188+
| 'shellscript' | 'bash' | 'sh' | 'shell' | 'zsh'
189+
| 'shellsession' | 'console'
189190
| 'smalltalk'
190191
| 'solidity'
191192
| 'sparql'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "shellsession",
3+
"scopeName": "text.shell-session",
4+
"patterns": [
5+
{
6+
"match": "(?x) ^ (?: ( (?:\\(\\S+\\)\\s*)? (?: sh\\S*? | \\w+\\S+[@:]\\S+(?:\\s+\\S+)? | \\[\\S+?[@:][^\\n]+?\\].*? ) ) \\s* )? ( [>$#%❯➜] | \\p{Greek} ) \\s+ (.*) $",
7+
"captures": {
8+
"1": {
9+
"name": "entity.other.prompt-prefix.shell-session"
10+
},
11+
"2": {
12+
"name": "punctuation.separator.prompt.shell-session"
13+
},
14+
"3": {
15+
"name": "source.shell",
16+
"patterns": [
17+
{
18+
"include": "source.shell"
19+
}
20+
]
21+
}
22+
}
23+
},
24+
{
25+
"name": "meta.output.shell-session",
26+
"match": "^.+$"
27+
}
28+
],
29+
"fileTypes": ["sh-session"]
30+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
$ echo $EDITOR
2+
vim
3+
$ git checkout main
4+
Switched to branch 'main'
5+
Your branch is up-to-date with 'origin/main'.
6+
$ git push
7+
Everything up-to-date
8+
$ echo 'All
9+
> done!'
10+
All
11+
done!
12+
13+
# From https://github.com/highlightjs/highlight.js/blob/fcefad4a6bf99b88c54b2b724ca77466e94c374d/test/detect/shell/default.txt#L4

packages/shiki/src/languages.ts

+13-3
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ export type Lang =
135135
| 'scheme'
136136
| 'scss'
137137
| 'shaderlab' | 'shader'
138-
| 'shellscript' | 'bash' | 'console' | 'sh' | 'shell' | 'zsh'
138+
| 'shellscript' | 'bash' | 'sh' | 'shell' | 'zsh'
139+
| 'shellsession' | 'console'
139140
| 'smalltalk'
140141
| 'solidity'
141142
| 'sparql'
@@ -827,6 +828,7 @@ export const languages: ILanguageRegistration[] = [
827828
scopeName: 'text.marko',
828829
path: 'marko.tmLanguage.json',
829830
displayName: 'Marko',
831+
samplePath: 'marko.sample',
830832
embeddedLangs: ['css', 'less', 'scss', 'javascript']
831833
},
832834
{
@@ -840,7 +842,7 @@ export const languages: ILanguageRegistration[] = [
840842
scopeName: 'source.mdx',
841843
path: 'mdx.tmLanguage.json',
842844
displayName: 'MDX',
843-
embeddedLangs: ['tsx', 'toml', 'yaml', 'c', 'clojure', 'coffee', 'cpp', 'csharp', 'css', 'diff', 'docker', 'elixir', 'elm', 'erlang', 'go', 'graphql', 'haskell', 'html', 'ini', 'java', 'javascript', 'json', 'julia', 'kotlin', 'less', 'lua', 'make', 'markdown', 'objective-c', 'perl', 'python', 'r', 'ruby', 'rust', 'scala', 'scss', 'shellscript', 'sql', 'xml', 'swift', 'typescript']
845+
embeddedLangs: ['tsx', 'toml', 'yaml', 'c', 'clojure', 'coffee', 'cpp', 'csharp', 'css', 'diff', 'docker', 'elixir', 'elm', 'erlang', 'go', 'graphql', 'haskell', 'html', 'ini', 'java', 'javascript', 'json', 'julia', 'kotlin', 'less', 'lua', 'make', 'markdown', 'objective-c', 'perl', 'python', 'r', 'ruby', 'rust', 'scala', 'scss', 'shellscript', 'shellsession', 'sql', 'xml', 'swift', 'typescript']
844846
},
845847
{
846848
id: 'mermaid',
@@ -1105,7 +1107,15 @@ export const languages: ILanguageRegistration[] = [
11051107
scopeName: 'source.shell',
11061108
path: 'shellscript.tmLanguage.json',
11071109
displayName: 'Shell',
1108-
aliases: ['bash', 'console', 'sh', 'shell', 'zsh']
1110+
aliases: ['bash', 'sh', 'shell', 'zsh']
1111+
},
1112+
{
1113+
id: 'shellsession',
1114+
scopeName: 'text.shell-session',
1115+
path: 'shellsession.tmLanguage.json',
1116+
displayName: 'Shell Session',
1117+
aliases: ['console'],
1118+
embeddedLangs: ['shellscript']
11091119
},
11101120
{
11111121
id: 'smalltalk',

scripts/grammarSources.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ export const githubGrammarSources: [string, string][] = [
272272
'https://github.com/scala/vscode-scala-syntax/blob/master/syntaxes/Scala.tmLanguage.json'
273273
],
274274
['scheme', 'https://github.com/sjhuangx/vscode-scheme/blob/master/syntaxes/scheme.tmLanguage'],
275+
['shellsession', 'https://github.com/hronro/sublime-linguist-syntax/blob/master/syntaxes/ShellSession.tmLanguage'],
275276
[
276277
'smalltalk',
277278
'https://github.com/leocamello/vscode-smalltalk/blob/master/syntaxes/smalltalk.tmLanguage.json'
@@ -373,7 +374,8 @@ export const languageAliases = {
373374
rust: ['rs'],
374375
'html-ruby-erb': ['erb'],
375376
shaderlab: ['shader'],
376-
shellscript: ['bash', 'console', 'sh', 'shell', 'zsh'],
377+
shellscript: ['bash', 'sh', 'shell', 'zsh'],
378+
shellsession: ['console'],
377379
stylus: ['styl'],
378380
typescript: ['ts'],
379381
vb: ['cmd'],

0 commit comments

Comments
 (0)