etc.kak (4630B)
1 # Highlighting for common files in /etc 2 hook global BufCreate .*/etc/(hosts|networks|services) %{ set-option buffer filetype etc-hosts } 3 hook global BufCreate .*/etc/resolv.conf %{ set-option buffer filetype etc-resolv-conf } 4 hook global BufCreate .*/etc/shadow %{ set-option buffer filetype etc-shadow } 5 hook global BufCreate .*/etc/passwd %{ set-option buffer filetype etc-passwd } 6 hook global BufCreate .*/etc/gshadow %{ set-option buffer filetype etc-gshadow } 7 hook global BufCreate .*/etc/group %{ set-option buffer filetype etc-group } 8 hook global BufCreate .*/etc/(fs|m)tab %{ set-option buffer filetype etc-fstab } 9 hook global BufCreate .*/etc/environment %{ set-option buffer filetype sh } 10 hook global BufCreate .*/etc/env.d/.* %{ set-option buffer filetype sh } 11 hook global BufCreate .*/etc/profile(\.(csh|env))? %{ set-option buffer filetype sh } 12 hook global BufCreate .*/etc/profile\.d/.* %{ set-option buffer filetype sh } 13 14 15 hook global WinSetOption filetype=etc-(hosts|resolv-conf|shadow|passwd|gshadow|group|fstab) %{ 16 require-module "etc-%val{hook_param_capture_1}" 17 } 18 19 20 hook -group etc-resolv-conf-highlight global WinSetOption filetype=etc-resolv-conf %{ 21 add-highlighter window/etc-resolv-conf ref etc-resolv-conf 22 hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-resolv-conf } 23 } 24 hook -group etc-hosts-highlight global WinSetOption filetype=etc-hosts %{ 25 add-highlighter window/etc-hosts ref etc-hosts 26 hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-hosts } 27 } 28 hook -group etc-fstab-highlight global WinSetOption filetype=etc-fstab %{ 29 add-highlighter window/etc-fstab ref etc-fstab 30 hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-fstab } 31 } 32 hook -group etc-group-highlight global WinSetOption filetype=etc-group %{ 33 add-highlighter window/etc-group ref etc-group 34 hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-group } 35 } 36 hook -group etc-gshadow-highlight global WinSetOption filetype=etc-gshadow %{ 37 add-highlighter window/etc-gshadow ref etc-gshadow 38 hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-gshadow } 39 } 40 hook -group etc-shadow-highlight global WinSetOption filetype=etc-shadow %{ 41 add-highlighter window/etc-shadow ref etc-shadow 42 hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-shadow } 43 } 44 hook -group etc-passwd-highlight global WinSetOption filetype=etc-passwd %{ 45 add-highlighter window/etc-passwd ref etc-passwd 46 hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-passwd } 47 } 48 49 50 # Highlighters 51 52 provide-module etc-resolv-conf %{ 53 ## /etc/resolv.conf 54 add-highlighter shared/etc-resolv-conf group 55 add-highlighter shared/etc-resolv-conf/ regex ^#.*?$ 0:comment 56 add-highlighter shared/etc-resolv-conf/ regex ^(nameserver|server|domain|sortlist|options)[\s\t]+(.*?)$ 1:type 2:attribute 57 } 58 59 provide-module etc-hosts %{ 60 ## /etc/hosts 61 add-highlighter shared/etc-hosts group 62 add-highlighter shared/etc-hosts/ regex ^(.+?)[\s\t]+?(.*?)$ 1:type 2:attribute 63 add-highlighter shared/etc-hosts/ regex '#.*?$' 0:comment 64 } 65 66 provide-module etc-fstab %{ 67 ## /etc/fstab 68 add-highlighter shared/etc-fstab group 69 add-highlighter shared/etc-fstab/ regex ^(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})(?:\s+)?$ 1:keyword 2:value 3:type 4:string 5:attribute 6:attribute 70 add-highlighter shared/etc-fstab/ regex '#.*?$' 0:comment 71 } 72 73 provide-module etc-group %{ 74 ## /etc/group 75 add-highlighter shared/etc-group group 76 add-highlighter shared/etc-group/ regex ^(\S+?):(\S+?)?:(\S+?)?:(\S+?)?$ 1:keyword 2:type 3:value 4:string 77 } 78 79 provide-module etc-gshadow %{ 80 ## /etc/gshadow 81 add-highlighter shared/etc-gshadow group 82 add-highlighter shared/etc-gshadow/ regex ^(\S+?):(\S+?)?:(\S+?)?:(\S+?)?$ 1:keyword 2:type 3:value 4:string 83 } 84 85 provide-module etc-shadow %{ 86 ## /etc/shadow 87 add-highlighter shared/etc-shadow group 88 add-highlighter shared/etc-shadow/ regex ^(\S+?):(\S+?):([0-9]+?):([0-9]+?)?:([0-9]+?)?:([0-9]+?)?:([0-9]+?)?:([0-9]+?)?:(.*?)?$ 1:keyword 2:type 3:value 4:value 5:value 6:value 7:value 8:value 89 } 90 91 provide-module etc-passwd %{ 92 ## /etc/passwd 93 add-highlighter shared/etc-passwd group 94 add-highlighter shared/etc-passwd/ regex ^(\S+?):(\S+?):([0-9]+?):([0-9]+?):(.*?)?:(.+?):(.+?)$ 1:keyword 2:type 3:value 4:value 5:string 6:attribute 7:attribute 95 }