По умолчанию этот редактор имеет подсветку синтаксиса лишь для некоторых типов файлов
Для включения цвета всем пользователям раскомментируем все инклуды в файле:
/etc/nanorc
sed -i "s|# include|include|" /etc/nanorc
Создадим файл:
/usr/share/nano/mysettings.nanorc
со следующим содержимым
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 |
<span style="color: #646b86; font-size: 12pt; font-family: georgia, palatino, serif;"><span class="hljs-preprocessor"># config file highlighting</span> <span class="hljs-preprocessor">syntax <span class="hljs-title">"conf" </span><span class="hljs-title">"(\.(conf|config|cfg|cnf|rc|lst|list|defs|ini|desktop|mime|types|preset|cache|seat|service|htaccess)$|(^|/)(\w*crontab|mirrorlist|group|hosts|passwd|rpc|netconfig|shadow|fstab|inittab|inputrc|protocols|sudoers)$|conf.d/|.config/)"</span></span> <span class="hljs-preprocessor"># default text</span> <span class="hljs-preprocessor">color magenta <span class="hljs-title">"^.*$"</span></span> <span class="hljs-preprocessor"># special values</span> <span class="hljs-preprocessor">icolor brightblue <span class="hljs-title">"(^|\s|=)(default|true|false|on|off|yes|no)(\s|$)"</span></span> <span class="hljs-preprocessor"># keys</span> <span class="hljs-preprocessor">icolor cyan <span class="hljs-title">"^\s*(set\s+)?[A-Z0-9_\/\.\%\@+-]+\s*([:]|\>)"</span></span> <span class="hljs-preprocessor"># commands</span> <span class="hljs-preprocessor">color blue <span class="hljs-title">"^\s*set\s+\<"</span></span> <span class="hljs-preprocessor"># punctuation</span> <span class="hljs-preprocessor">color blue <span class="hljs-title">"[.]"</span></span> <span class="hljs-preprocessor"># numbers</span> <span class="hljs-preprocessor">color red <span class="hljs-title">"(^|\s|[[/:|<>(){}=,]|\])[-+]?[0-9](\.?[0-9])*%?($|\>)"</span></span> <span class="hljs-preprocessor"># keys</span> <span class="hljs-preprocessor">icolor cyan <span class="hljs-title">"^\s*(\$if )?([A-Z0-9_\/\.\%\@+-]|\s)+="</span></span> <span class="hljs-preprocessor"># punctuation</span> <span class="hljs-preprocessor">color blue <span class="hljs-title">"/"</span></span> <span class="hljs-preprocessor">color brightwhite <span class="hljs-title">"(\]|[()<>[{},;:=])"</span></span> <span class="hljs-preprocessor">color brightwhite <span class="hljs-title">"(^|\[|\{|\:)\s*-(\s|$)"</span></span> <span class="hljs-preprocessor"># section headings</span> <span class="hljs-preprocessor">icolor brightyellow <span class="hljs-title">"^\s*(\[([A-Z0-9_\.-]|\s)+\])+\s*$"</span></span> <span class="hljs-preprocessor">color brightcyan <span class="hljs-title">"^\s*((Sub)?Section\s*(=|\>)|End(Sub)?Section\s*$)"</span></span> <span class="hljs-preprocessor">color brightcyan <span class="hljs-title">"^\s*\$(end)?if(\s|$)"</span></span> <span class="hljs-preprocessor"># URLs</span> <span class="hljs-preprocessor">icolor green <span class="hljs-title">"\b(([A-Z]+://|www[.])[A-Z0-9/:#?&$=_\.\-]+)(\b|$| )"</span></span> <span class="hljs-preprocessor"># XML-like tags</span> <span class="hljs-preprocessor">icolor brightcyan <span class="hljs-title">"</?\w+((\s*\w+\s*=)?\s*("</span>[^<span class="hljs-title">"]*"</span>|'[^']*'|!?[A-Z0-9_:/]))*(\s*/)?><span class="hljs-title">"</span></span> <span class="hljs-preprocessor"><span class="hljs-title"># strings</span></span> <span class="hljs-preprocessor"><span class="hljs-title">color yellow "</span>\<span class="hljs-title">"(\\.|[^"</span>])*\<span class="hljs-title">""</span><span class="hljs-title">"'(\\.|[^'])*'"</span></span> <span class="hljs-preprocessor"># comments</span> <span class="hljs-preprocessor">color white <span class="hljs-title">"#.*$"</span></span> <span class="hljs-preprocessor">color blue <span class="hljs-title">"^\s*##.*$"</span></span> <span class="hljs-preprocessor">color white <span class="hljs-title">"^;.*$"</span></span> <span class="hljs-preprocessor">color white start=<span class="hljs-title">"<!--"</span> end=<span class="hljs-title">"-->"</span></span> После чего выполним команду:</span> |
1 |
<span style="font-size: 12pt;"><strong><span style="font-family: 'times new roman', times, serif;">find /usr/share/nano/ -iname "*.nanorc" -exec echo include {} \; >> ~/.nanorc</span></strong></span> |
ниже предоставлена ссылка на скрипт автоматической установки: