-
Notifications
You must be signed in to change notification settings - Fork 4
/
SSH Common.sublime-syntax
129 lines (111 loc) · 4.66 KB
/
SSH Common.sublime-syntax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
%YAML 1.2
---
# This file is some kind of internal library which is used to store
# common rules which are used by the visible syntax files.
name: SSH Common
hidden: true
scope: text.ssh.common
variables:
ssh_fingerprint: (?:AAAA(?:E2V|[BC]3N)[\w+/]+={0,3})
# ipv4_basic: (?:(?:\d{1,3}\.){3}\d{1,3})
# ipv6_basic: (?i:(?:[a-f0-9:]+:+)+[a-f0-9]+)
zero_to_255: (?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9][0-9])|(?:[1-9][0-9])|[0-9])
ipv4: (?:(?:{{zero_to_255}}\.){3}{{zero_to_255}})
ipv6: |-
(?xi:
(?:::(?:ffff(?::0{1,4}){0,1}:){0,1}{{ipv4}}) # ::255.255.255.255 ::ffff:255.255.255.255 ::ffff:0:255.255.255.255 (IPv4-mapped IPv6 addresses and IPv4-translated addresses)
|(?:(?:[0-9a-f]{1,4}:){1,4}:{{ipv4}}) # 2001:db8:3:4::192.0.2.33 64:ff9b::192.0.2.33 (IPv4-Embedded IPv6 Address)
|(?:fe80:(?::[0-9a-f]{1,4}){0,4}%[0-9a-z]{1,}) # fe80::7:8%eth0 fe80::7:8%1 (link-local IPv6 addresses with zone index)
|(?:(?:[0-9a-f]{1,4}:){7,7} [0-9a-f]{1,4}) # 1:2:3:4:5:6:7:8
| (?:[0-9a-f]{1,4}: (?::[0-9a-f]{1,4}){1,6}) # 1::3:4:5:6:7:8 1::3:4:5:6:7:8 1::8
|(?:(?:[0-9a-f]{1,4}:){1,2}(?::[0-9a-f]{1,4}){1,5}) # 1::4:5:6:7:8 1:2::4:5:6:7:8 1:2::8
|(?:(?:[0-9a-f]{1,4}:){1,3}(?::[0-9a-f]{1,4}){1,4}) # 1::5:6:7:8 1:2:3::5:6:7:8 1:2:3::8
|(?:(?:[0-9a-f]{1,4}:){1,4}(?::[0-9a-f]{1,4}){1,3}) # 1::6:7:8 1:2:3:4::6:7:8 1:2:3:4::8
|(?:(?:[0-9a-f]{1,4}:){1,5}(?::[0-9a-f]{1,4}){1,2}) # 1::7:8 1:2:3:4:5::7:8 1:2:3:4:5::8
|(?:(?:[0-9a-f]{1,4}:){1,6} :[0-9a-f]{1,4}) # 1::8 1:2:3:4:5:6::8 1:2:3:4:5:6::8
|(?:(?:[0-9a-f]{1,4}:){1,7} :) # 1:: 1:2:3:4:5:6:7::
|(?::(?:(?::[0-9a-f]{1,4}){1,7}|:)) # ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::
)
contexts:
main:
- include: comments-number-sign
pop-nl:
- match: \n
pop: true
pop-before-nl:
- match: (?=\n)
pop: true
comments-number-sign:
- match: ^\s*(#)
captures:
1: comment.line.number-sign.ssh.common punctuation.definition.comment.ssh.common
push:
- meta_content_scope: comment.line.number-sign.ssh.common
- include: pop-nl
comments-semicolon:
- match: ^\s*(;)
captures:
1: comment.line.number-sign.ssh.common punctuation.definition.comment.ssh.common
push:
- meta_content_scope: comment.line.semi-colon.ssh.common
- include: pop-nl
ssh-fingerprint:
- match: '{{ssh_fingerprint}}'
scope: variable.other.fingerprint.ssh.common
ssh-fingerprint-with-label:
- match: '{{ssh_fingerprint}}'
scope: variable.other.fingerprint.ssh.common
push:
- include: pop-before-nl
- match: '[ \t]*(\S(?:.*\S)?)[ \t]*$'
captures:
1: meta.annotation.identifier.ssh.common string.unquoted.ssh.common
pop: true
time-values:
# seconds, minutes, hours, days, weeks
- match: \b(\d+)(?i:([smhdw]))(?=[\d\s,"])
scope: meta.constant.date.ssh.common
captures:
1: constant.numeric.integer.decimal.ssh.common
2: storage.modifier.unit.ssh.common
bytes-values:
- match: \b(\d+)([KMG])(?=[\s,"])
scope: meta.constant.bytes.ssh.common
captures:
1: constant.numeric.integer.decimal.ssh.common
2: storage.modifier.unit.ssh.common
mac-addresses:
- match: (?:[0-9a-fA-F]{2}:){5}(?:[0-9a-fA-F]{2})
scope: entity.name.constant.mac-address.ssh.common
ipv4:
- match: '\b{{ipv4}}\b'
scope: constant.numeric.ip-address.v4.ssh.common
ipv6:
- match: '{{ipv6}}'
scope: constant.numeric.ip-address.v6.ssh.common
ipv6-square-bracket:
- match: (\[){{ipv6}}(\])
scope: constant.numeric.ip-address.v6.ssh.common
captures:
1: punctuation.definition.constant.begin.ssh.common
2: punctuation.definition.constant.end.ssh.common
ip-addresses:
- include: ipv6
- include: ipv4
ipv4-with-cidr:
# CIDR 0-32
- match: \b({{ipv4}})(?:(/)(3[0-2]|[12]\d|\d))?\b
captures:
1: constant.numeric.ip-address.v4.ssh.common
2: punctuation.separator.sequence.ssh.common
3: constant.other.range.ssh.common
ipv6-with-cidr:
# CIDR 0-128
- match: ({{ipv6}})(?:(/)(12[0-8]|1[01]\d|[1-9]\d|\d)\b)?
captures:
1: constant.numeric.ip-address.v6.ssh.common
2: punctuation.separator.sequence.ssh.common
3: constant.other.range.ssh.common
ip-addresses-with-cidr:
- include: ipv6-with-cidr
- include: ipv4-with-cidr