четверг, 3 июля 2014 г.

Nano: подсветка синтаксиса конфигурационных файлов.

Создаем файл /usr/share/config.nanorc следующего содержания:

# config file highlighting 
syntax "conf" "(\.([A-Za-z0-9])*(rc)$)|(\.(conf|config|cfg|cnf|profile|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/)" 
# default text 
color magenta "^.*$" 
# special values 
icolor brightblue "(^|\s|=)(default|true|false|on|off|yes|no)(\s|$)" # keys 
icolor cyan "^\s*(set\s+)?[A-Z0-9_\/\.\%\@+-]+\s*([:]|\>)" 
# commands 
color blue "^\s*set\s+\<" 
# punctuation 
color blue "[.]" 
# numbers 
color red "(^|\s|[[/:|<>(){}=,]|\])[-+]?[0-9](\.?[0-9])*%?($|\>)" 
# keys 
icolor cyan "^\s*(\$if )?([A-Z0-9_\/\.\%\@+-]|\s)+=" 
# punctuation 
color blue "/" 
color brightwhite "(\]|[()<>[{},;:=])" 
color brightwhite "(^|\[|\{|\:)\s*-(\s|$)" 
# section headings 
icolor brightyellow "^\s*(\[([A-Z0-9_\.-]|\s)+\])+\s*$" 
color brightcyan "^\s*((Sub)?Section\s*(=|\>)|End(Sub)?Section\s*$)" color brightcyan "^\s*\$(end)?if(\s|$)" 
# URLs 
icolor green "\b(([A-Z]+://|www[.])[A-Z0-9/:#?&$=_\.\-]+)(\b|$| )" 
# XML-like tags 
icolor brightcyan "</?\w+((\s*\w+\s*=)?\s*("[^"]*"|'[^']*'|!?[A-Z0-9_:/]))*(\s*/)?>" 
# strings 
color yellow "\"(\\.|[^"])*\"" "'(\\.|[^'])*'" 
# comments 
color white "#.*$" 
color blue "^\s*##.*$" 
color white "^;.*$" 
color white start="<!--" end="-->"

И ссылаемся на него в конфиге нано (.nanorc)
include "/usr/share/nano/config.nanorc"

set autoindent  #автоотступ последующих строк как у предыдущих
set smarthome   #автовозврат к первому значимому символу строки
set const       #показ номера текущей строки и позиции в строке

 

Комментариев нет :

Отправить комментарий