Page Contents
Nano syntax highlighting
- Save asterisk.nanorc e.g. in /usr/local/share/nano/asterisk.nanorc
- Add include “/usr/local/share/nano/asterisk.nanorc” to either /etc/nanorc or ~/.nanorc
asterisk.nanorc
My current suggestion
I have modified some colors to make it all visible on my light background, added colour for technology and made it highlight contexts. The keyword regex could be optimized, I will work on that part.
Updated 2007-11-18, optimized (hopefully) the application regex, added some other stuff.
Updated 2011-07-17, changing colour for priority “1” to blue. (Csabka)
Updated 2014-10-1, enabled syntax highlighting files named extensions.conf. (imcdona)
## Asterisk syntax highlighting
## v.03 2007-11-18
## Comments/updates - [email protected]
## Modified by Johan Adler from 2007-11-17 and forward, tested using Debian and Asterisk 1.2.13
## 2007-11-18
## Currently optimized for dialplan (extensions.conf and any included files)
## Application regex altered and hopefully optimized.
## Note that the order of regex's is important
## color is case sensitive, icolor case insensitive
syntax "asterisk" "/.*/asterisk/.*\.conf$|extensions.conf"
## Separating characters
color green "(\{|\}|\(|\)|\]|\[|`|\\|\$|<|>|!|=|&|\|)"
## Labels
color blue "^(\s)*exten(\s)*=>(\s)*((s|t|a|i|o|fax)|[0-9*#]+|_([XZN0-9*#]*(\[[XZN0-9*#]*\])*[XZN0-9*#]*)*(\.)?),([0-9]|n)\([A-Za-z0-9_\-]+\)"
## Priorities
color green "^(\s)*exten(\s)*=>(\s)*((s|t|a|i|o|fax)|[0-9*#]+|_([XZN0-9*#]*(\[[XZN0-9*#]*\])*[XZN0-9*#]*)*(\.)?),([02-9]|n)"
color blue "^(\s)*exten(\s)*=>(\s)*((s|t|a|i|o|fax)|[0-9*#]+|_([XZN0-9*#]*(\[[XZN0-9*#]*\])*[XZN0-9*#]*)*(\.)?),(1)"
## Comma back to black
color black "^(\s)*exten(\s)*=>(\s)*((s|t|a|i|o|fax)|[0-9*#]+|_([XZN0-9*#]*(\[[XZN0-9*#]*\])*[XZN0-9*#]*)*(\.)?),"
## Extensions
color red "^(\s)*exten(\s)*=>(\s)*((s|t|a|i|o|fax)|[0-9*#]+|_([XZN0-9*#]*(\[[XZN0-9*#]*\])*[XZN0-9*#]*)*(\.)?)"
## Word 'exten' in dialplan
color magenta "^(\s)*exten(\s)*=>"
## included context
color green "^(\s)*include(\s)*=>(\s)*\<.+\>"
## 'include' in dialplan
color magenta "^(\s)*include(\s)*=>"
## Conditionals
color blue "\$\[.+\]"
## Contexts
color green "^\[.+\]"
## Strings
color magenta ""(\\.|[^"])*"" "'(\\.|[^'])*'"
## Technologies
color magenta "\<(SIP/|IAX2/|Zap/|Local/).*\>"
## Anything following NoOp, same color as comments (will not be executed)
## Colored before variables, since they will be substituted
color yellow "\<NoOp\>.*"
## Variables (read mode)
## May or may not be appropriate, it is a bit too hairy at the moment
color red "\$\{?[0-9A-Za-z_!@#%,:$*?-]+(\([A-Za-z0-9_$\{\}\(\)/!@%:,#*?]+\))?\}?"
## Applications
color cyan "\<(A(DSIProg|gent(((Callback)?Login)|MonitorOutgoing)|GI|larmReceiver|MD|nswer|ppendCDRUserField|uthenticate))\>"
color cyan "\<(B(ackground(Detect)?|usy))\>"
color cyan "\<(C(han(geMonitor|IsAvail|nelRedirect|Spy)|on(gestion|t(inueWhile|rolPlayback))))\>"
color cyan "\<(D(ateTime|Bdel(tree)?|eadAGI|i(al|ctate|rectory)|ISA|umpChan))\>"
color cyan "\<(E(AGI|cho|ndWhile|x(ec(If|While)?)|itWhile|te(nSpy|rnalIVR)))\>"
color cyan "\<(F(astAGI|estival|lash|orkCDR))\>"
color cyan "\<(G(etPEID|o(sub(if)?|to(If(Time)?)?)))\>"
color cyan "\<(Ha(ngup|s(New)?Voicemail))\>"
color cyan "\<(I(AX2Provision|CES|mportVar))\>"
color cyan "\<(Lo(g|okup(Blacklist|CIDName)))\>"
color cyan "\<(M(a(cro((Ex(clusive)|it)?|(If)?)|ilboxExists)|eetMe(Admin|Count)?|illiwatt|o(nitor|rseCode)|P3Player|usicOnHold))\>"
color cyan "\<(N(BScat|o(CDR|Op)))\>"
color cyan "\<(P(a(ge|rk(AndAnnounce|edCall)?|use(Monitor|QueueMember))|ickUp|lay(back|tones)|r(ivacyManager|ogress)))\>"
color cyan "\<(Queue(Log)?)\>"
color cyan "\<(R(andom|e(a((d(File)?)lTime(Update)?)|cord|moveQueueMember|setCDR|t(ryDial|urn))|inging))\>"
color cyan "\<(S(ay(Alpha|Digits|Number|Phonetic|UnixTime)|e(nd(DTMF|Image|Text|URL)|t(AMAFlags|Caller(ID|Pres)|CDRUserField|GlobalVar|MusicOnHold|TransferCapability)?)|IP(AddHeader|DtmfMode)|LA(Station|Trunk)|oftHangup|t(a(ckPop|rtMusicOnHold)|op(MixMonitor|Monitor|PlayTones|MusicOnHold))|ystem))\>"
color cyan "\<(Tr(ansfer|y(Exec|System)))\>"
color cyan "\<(U(npause(Monitor|QueueMember)|erEvent))\>"
color cyan "\<(V(erbose|MAuthenticate|oiceMail(Main)?))\>"
color cyan "\<(W(ait(Exten|For(Ring|Silence)|MusicOnHold)?|hile))\>"
color cyan "\<(Zap(ateller|Barge|RAS|Scan))\>"
## Functions
## to be implemented
## something else
icolor brightgreen "^[0-9A-Z_]+\(\)"
## color all curly braces (why?)
##color blue "[\{\}]"
## Comments
color yellow ";.*"
Jim Canfields original
## Asterisk syntax highlighting
## v.01 09/28/07 - Asterisk Version 1.4.11
## Comments/updates - [email protected]
syntax "conf" "\.conf$"
icolor brightgreen "^[0-9A-Z_]+\(\)"
color magenta "\<exten\>"
icolor cyan "\<(ADSIProg|AgentCallbackLogin|AgentLogin|AgentMonitorOutgoing|AGI|AlarmReceiver|AMD|Answer|AppendCDRUserField|Authenticate|Background|BackgroundDetect|Busy|ChangeMonitor|ChanIsAvail|ChannelRedirect|ChanSpy|Congestion|ContinueWhile|ControlPlayback|DateTime|DBdel|DBdeltree|DeadAGI|Dial|Dictate|Directory|DISA|DumpChan|EAGI|Echo|EndWhile|Exec|ExecIf|ExitWhile|ExtenSpy|ExternalIVR|FastAGI|Festival|Flash|ForkCDR|GetPEID|Gosub|Gosubif|Goto|GotoIf|GotoIfTime|Hangup|HasNewVoicemail|HasVoicemail|IAX2Provision|ICES|ImportVar|Log|LookupBlacklist|LookupCIDName|Macro|MacroExclusive|MacroExit|MacroIf|MailboxExists|MeetMe|MeetmeAdmin|MeetMeCount|Milliwatt|Monitor|MorseCode|MP3Player|MusicOnHold|NBScat|NoCDR|NoOp|Page|Park|ParkAndAnnounce|ParkedCall|PauseMonitor|PauseQueueMember|PickUp|Playback|Playtones|PrivacyManager|Progress|Queue|QueueLog|Random|Read|ReadFile|RealTime|RealTimeUpdate|Record|RemoveQueueMember|ResetCDR|RetryDial|Return|Ringing|SayAlpha|SayDigits|SayNumber|SayPhonetic|SayUnixTime|SendDTMF|SendImage|SendText|SendURL|Set|SetAMAFlags|SetCallerID|SetCallerPres|SetCDRUserField|SetGlobalVar|SetMusicOnHold|SetTransferCapability|SIPAddHeader|SIPDtmfMode|SLAStation|SLATrunk|SoftHangup|StackPop|StartMusicOnHold|StopMixMonitor|StopMonitor|StopPlaytones|StopMusicOnHold|System|Transfer|TryExec|TrySystem|UnpauseMonitor|UnpauseQueueMember|UserEvent|Verbose|VMAuthenticate|VoiceMail|VoiceMailMain|Wait|WaitExten|WaitForRing|WaitForSilence|WaitMusicOnHold|While|Zapateller|ZapBarge|ZapRAS|ZapScan)\>"
color green "(\{|\}|\(|\)|\]|\[|`|\\|\$|<|>|!|=|&|\|)"
color yellow "_[XZN0-9]*\>"
icolor red "\$\{?[0-9A-Z_!@#$*?-]+\}?"
color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"
color red "[\{\}]"
color blue ";.*"